Upload Image using App42 upload service

0 votes

Hello Guys,
 

I have already added my question on the support but still I hav'nt get any response on that.

Do I have to create a new question every time.

I am trying to upload an image using App42 upload service. But I am not able to do so.
Basically, what I am doing, I had created a form on in which I accept an image to be uploaded. But I am not able to upload the file on the App42.
so can you explain to me what "Your local file path" refer to cause I had tried to upload from the local file path, but I got an exception 400 The Request parameters are invalid. The parameter 'File' cannot be null or empty
 

  1. $fileName = "<Your_file_name>";     
  2. $fileType = "<Your_file_type>";     
  3. $filePath = "Your Local File Path";   
  4. $description = "File Description";
asked Feb 22 in PHP by krishnji.axovel (11 points)
Also I am adding the code

<?php
include_once 'App42/2.6/App42Response.php';    
include_once 'App42/2.6/App42Exception.php';    
include_once 'App42/2.6/App42BadParameterException.php';    
include_once 'App42/2.6/App42NotFoundException.php';  
include_once 'App42/2.6/App42Log.php';    
include_once 'App42/2.6/UploadService.php';
include_once 'App42/2.6/UploadFileType.php';
App42API::initialize("3f129a4d967bb3c947596a95abe3d6fc46e816e1e0a87a91e13b976b30b6910f","1ee3c687f9006369e7c5fb3a3ac0cec885064bd18f7b50a6790518fc21d11174");   
$uploadService = App42API::buildUploadService();
try{
    $fileName = "Upload.jpg";     
    $fileType = UploadFileType::IMAGE;     
    $filePath = realpath("Upload.jpg");   
    $description = "File Description";
    $upload = $uploadService->uploadFile($fileName, $filePath, $fileType, $description);
    $fileList = $upload->getFileList();   
    foreach($fileList as $files )  {      
        print_r("FileName is : ".$files->getName());      
        print_r("Type is : ".$files->getType() );      
        print_r("Url is : ".$files->getUrl() );      
        print_r("TinyUrl is: ".$files->getTinyUrl() );      
        print_r("Description is: ".$files->getDescription());  
    }  
    $jsonResponse = $upload->toString();
} catch(App42Exception $exception) {
    var_dump($exception->getMessage());
}  
var_dump($filePath);
?>

1 Answer

–1 vote

Hi Krishnji,

We have tested this on our side and if the file path is correct then it is working fine. Below is the code with which we tested:
     
$uploadService = App42API::buildUploadService();
$fileName = "Name of the file1" ;
$uploadObj = $uploadService->uploadFile($fileName, "E:\\a.jpg",UploadFileType::IMAGE, "Description");
   
In the above code snippet, we have given te exact path of the file in the second parameter in the API call. Please check the same once at your end and let me know if you still faces the same problem.

 

answered Feb 23 by rajeev.etc (1,558 points)
I have tested using that file_exits function and I get true in response and I also tried it using the static path like you do
But I get the same error
If required I can share the whole code also
It will be better if you can share a sample project in which we can reproduce this issue. Please share the same at support@shephertz.com. We will test the same sample project at our end will share you the working sample.
I have sent the source code so can you test it and let me know where I am getting it wrong.
You can also test the same code on the following link
http://192.241.153.62/temp/
Can we have a call to discuss this? If Yes, please take my contact number from Deepak in your team and call me tomorrow(Wednesday) or share your contact number so that I can call you.
Ok, I'll call you tomorrow, I want to know have you checked the code that I had sent and what the issue in that code cause of which I was not able to upload the image.
Hello Rajeev,
You can send me the other sample code to upload image on the following email I’d akash.axovel@gmail.com
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com