通过ajax将驻留在网站服务器上的文件上传到其他服务 [英] Upload a file that lives on the website server to another service via ajax

查看:115
本文介绍了通过ajax将驻留在网站服务器上的文件上传到其他服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上在网站服务器上,我有一个assets目录,其中一些通用文件。这些文件可以应用于不同数量的东西,比如关闭按钮的x_button.png,但也有在该目录中的config.json文件。我需要能够通过AJAX将这些文件中的任何一个推送到另一个服务器上。

目前我们使用文件对话框并且获得一个带有实际文件的文件数组,并使用formdata ,将其推送到服务器。

对于图像,我可以设置一个图像标签到本地位置,然后使用画布获取数据uri并将其更改为Blob,但我不确定是否有任何我可以做的.json文件,甚至进一步的任何文件类型。

我不寻找一个写出来的解决方案,只是如果有人遇到过这样的事情需要做这样的事情,那么就要解决问题的基本步骤。谢谢!

解决方案

您可以使用ajax调用php代码来通过ftp上传文件。 $ b

检查 ftp_exec



或者您可以使用>发送文件

I'm just wondering if what I propose is possible to do with any file, not just images.

Basically on the website server I have a assets directory with some generic files. These files can apply to a different number of things, like 'x_button.png' for a close button but there are also config.json files that are in that directory as well. I need the ability to push any one of these files to another server via AJAX.

Currently we use the file dialog and get a files array with the actual file and using formdata, push that up to the server.

For the images I could set an image tag to that local location then use the canvas to get the data uri and change that into a Blob but I am unsure if there is anything I can do for a .json file or even further any filetype.

I'm not looking for a written out solution, just if someone has encountered the need to do something like this before and the jist of the basic steps to solve the problem. Thanks!

解决方案

you can call a php code with ajax to upload file via ftp

check ftp_exec

or you may send the file using

这篇关于通过ajax将驻留在网站服务器上的文件上传到其他服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆