Show temporarily uploaded image file (PHP) [closed]
Can i show the uploaded image file before using move_uploaded_file function ? i want to show image file to user before its renamed and moved to image folder, so user can resize image or cancel opreation
yes ... you have to stream the file from temporary files eg /tmp
.
header('Content-Type: image/jpeg');
readfile('/tmp/'.$_FILES["file"]["tmp_name"]);
Yes you can,
but you have to first upload it, then show it to user, and when user clicks "Accept" or submit button then resize it and move it. Until then keep it in temp folder, temp folder on your server, or any other folder where you want to keep temp images.
A malicious user could upload something dodgy so I'd be sure you have some sort of validation in place before doing something like this. Either to check the file extension of the uploaded file or the mime-type. Or showing it through an image handling script instead i.e. viewImage.php?id=1234
精彩评论