简体   繁体   English

使用HTML Ajax PHP上传文件

[英]File upload using html ajax php

Previously i have performed submitting html page's data to php page by ajax using get or post method.Now i want to know suppose my html page have an input tag of type file in following way 以前我已经使用get或post方法通过ajax将html页面的数据提交到php页面。现在我想知道假设我的html页面具有以下类型的文件输入标签

<input type="file" name="image_file" id="image_file" />
<input type="button" id="btn_crop" onclick="btbn_click()" />

Now i want to perform that after clicking the button the file will be transferred to "crop.php" by ajax.I don't want to use the ajax file upload cause i wish to perform the cropping before storing the file in server hard disk page.Now can any body give me suggestion about this? 现在我要执行的操作是,单击按钮后文件将被ajax传输到“ crop.php”。我不想使用ajax文件上传,因为我希望在将文件存储到服务器硬盘之前执行裁剪现在,有人可以给我建议吗?

You might find this Nettuts+ tutorial helpful. 您可能会发现此Nettuts +教程很有帮助。 That's for uploading files with AJAX. 那是用AJAX上传文件。 Now, when the file gets transferred to your server, it is automatically stored in a temporary directory, from where you can move it after cropping it and whatsoever. 现在,将文件传输到服务器后,它会自动存储在一个临时目录中,您可以在该目录中裁剪文件后将其移动。 If you want, you can also try deleting it afterwards, I don't know. 不知道,如果需要,您也可以尝试稍后将其删除。

Try the GD functions for cropping. 尝试使用GD功能进行裁剪。 A good search will do the trick. 一个好的搜索将解决问题。

Hope I helped. 希望我能帮上忙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM