开发者

Show temporarily uploaded image file (PHP) [closed]

开发者 https://www.devze.com 2023-03-27 11:31 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. C开发者_StackOverflowlosed 10 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消