Get path to download temporary file with image extension in PHP

I have a form that allows the user to upload an image file.

<div id="imageDiv">
             Image Path : <input class="imageOption" type="file" id= "uploadImageFile" name="uploadImageFile"  >
             </div>

The problem occurs when I try to get the path from the temp folder. After processing the request, I will not need image files. When I try to get a path with something like this

$imagePath =  $_FILES['uploadImageFile']['tmp_name'];

The path looks like C: \ wamp \ tmp \ phpA123.tmp. The API I'm using will require a path with an extension of the uploaded image like this C: \ WAMP \ TMP \ image.png

Could not find a way to do this if I do not want to copy this image to another download folder and use it. I do not want these images to be registered on the server

thank

+6
3

API , API , . temp API .

L5:

// Get the UploadedFile object
$file = Request::file('uploadImageFile');

// You can store this but should validate it to avoid conflicts
$original_name = $file->getClientOriginalName();

// This would be used for the payload
$file_path = $file->getPathName();

// Example S3 API upload
$s3client->putObject([
    'Key' => $original_name, // This will overwrite any other files with same name
    'SourceFile' => $file_path,
    'Bucket' => 'bucket_name'
]);
+14

, -

$imagePath = $_FILES['uploadImageFile']['tmp_name'];

Laravel, - , @cdbconcepts -

$file = Request::file('uploadImageFile'); $imagePath = $file->getPathName()

+4

$ imagePath = $ _FILES ['uploadImageFile'] ['tmp_name'];

- $ imagePath = C:\wamp\tmp\phpA123.tmp

, $ imagePath = "" , .

, ???

0

All Articles