显示临时上传的图像文件(PHP)
我可以在使用 move_uploaded_file 函数之前显示上传的图像文件吗? 我想在重命名并移动到图像文件夹之前向用户显示图像文件,以便用户可以调整图像大小或取消操作
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的...您必须从临时文件(例如
/tmp
)流式传输文件。yes ... you have to stream the file from temporary files eg
/tmp
.是的,您可以,
但您必须首先上传它,然后将其显示给用户,当用户单击“接受”或提交按钮时,然后调整其大小并移动它。在此之前,请将其保存在临时文件夹、服务器上的临时文件夹或您想要保存临时图像的任何其他文件夹中。
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.
恶意用户可能会上传一些不可靠的内容,因此我确保在执行此类操作之前您已经进行了某种验证。检查上传文件的文件扩展名或 mime 类型。或者通过图像处理脚本显示它,即 viewImage.php?id=1234
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