php处理tmp文件夹中上传的图像/文件,然后再移动到另一个文件夹 [英] php manipulating uploaded images/files from the tmp folder before moving to another folder
问题描述
上传后,我一直在处理图像文件,例如将文件从/tmp文件夹移动到网站的首选文件夹.
I have been manipulating image files after uploading in the usual way like moving the file from the /tmp folder to a preferred folder of the site.
现在,我想通过将图像保存在temp文件夹中来进行操作,一旦完成操作,便要将其移动到首选文件夹中.
Now i want to manipulate images by keeping them in the temp folder and once i have done with it then i want to move it to the preferred folder.
我想做的是...
- 显示一个非常简单的自定义文件上传对话框.
- 选择一个图像,然后单击上载.
- 该表单已提交到iframe,因此我可以显示进度条.
- php脚本将回显javascript代码,该代码将从iframe调用父窗口函数,以通知图像已上传.
- 我想显示另一个对话框,该对话框将显示tmp文件夹中的图像,以便用户可以调整大小和裁剪.
- 当用户在图像上选择要裁剪的区域时,我会将坐标发送到服务器并在tmp文件夹中处理图像.
- 完成图像处理后,我希望将最终图像移动到目标文件夹中.
这是我的疑问.
- 临时图像将在tmp文件夹中保留多长时间.
- 由于只有物理路径,因此如何在对话框的temp文件夹中显示图像.
- 我想我可以像
<img src='fetchfromtmp.php?filename>
那样做.不是吗? -
,在php脚本中,我可以读取文件,例如readfile('tmp/tmpfile').
- How long will the temp image be there in the tmp folder.
- How do i display the image in the temp folder in my dialog box because i only have its physical path.
- I think i can do it like
<img src='fetchfromtmp.php?filename>
. isn't it? and in the php script i can readfile the image like readfile('tmp/tmpfile').
那么,最后,从temp文件夹进行操作会很好吗?它会有效/建议吗?可能是什么并发症?
我想为我的想法提供建议和替代方法. 谢谢.
I would like to have suggestions and alternatives for my idea. Thank you.
推荐答案
我不认为您应该使用这样的temp文件夹,不幸的是,您将不得不创建自己的文件夹(或使用数据库来存储图像) .原因是您的观点1和2:
I don't think you should use the temp folder like this, unfortunately, you will have to create your own (or use a database to store the images). The reasons are your point 1 & 2:
- 仅保证映像保留在temp文件夹中,直到上载该脚本的脚本运行完毕为止.这意味着无论您提交表单的脚本是什么,都应该将其移动到安全的地方
- 通常,此临时文件夹将位于用户不可见的位置.您可以按照建议的方式进行黑客入侵,但随后必须非常确定自己在做什么,以免造成任何安全漏洞.
这篇关于php处理tmp文件夹中上传的图像/文件,然后再移动到另一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!