小编Jon*_*oni的帖子

使用Javascript将我的服务器上的远程文件上传到第三方服务器

我正在使用PHP在我的服务器上创建一个图像文件.现在我需要通过POST将其上传到第三方的服务器.最简单的方法是使用服务器端cURL脚本来完成,但我必须通过我的客户端来完成,因为它需要在客户端和第三方服务器之间的活动会话的上下文中上传.问题是我如何才能实现这一最简单的目标?

  1. 是否可以使用说HTML表单或AJAX调用并通过提供URL来上传图像?问题是第三方后端不接受URL,需要将其表示为通过Web表单上传...

  2. 如果那是不可能的,我打算使用AJAX调用来下载图像并将内容保存到变量中.然后创建一个上传图像内容的表单,就像在表单中选择了本地文件一样.我该怎么做到这一点?

当我通过Web表单上传文件并查看正在发送的HTTP标头时,我看到如下所示:

------WebKitFormBoundary3ygta7rqeBm1krBO
Content-Disposition: form-data; name="MAX_FILE_SIZE"

10000000
------WebKitFormBoundary3ygta7rqeBm1krBO
Content-Disposition: form-data; name="uploadedfile"; filename="test.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary3ygta7rqeBm1krBO--
Run Code Online (Sandbox Code Playgroud)

我应该创建一个像这种格式的字符串,然后通过AJAX调用将其作为数据提交吗?我在哪里放置实际的二进制图像数据?我猜Chrome开发者工具会压制这些数据......

谢谢你的任何指示.

javascript file-upload

5
推荐指数
1
解决办法
1901
查看次数

带有清除历史记录的NativeScript / Angular嵌套路由问题

I have an issue with routing in NativeScript 3.4 that drives me nuts. The idea of this test project is that the root app component is using a <page-router-outlet> and then using nested angular routing using <router-outlet> it loads a login parent and child, through which I am navigating to a main page which has two child routes.

If I route from the login.child.ts to the main parent/child with this.router.navigate(['/main']); then everything works fine and I continue alternating between the …

nativescript angular2-nativescript

5
推荐指数
0
解决办法
392
查看次数