【问题标题】:PHP image Upload to Remote ServerPHP图像上传到远程服务器
【发布时间】:2014-12-01 12:06:32
【问题描述】:

我想把图片保存到这个'http://198.164.241.108/~bss/api/images/upload_images';location

我尝试了以下

$url = 'http://198.164.241.108/~bss/api/images/upload_images';

$img = $_FILES['image']['tmp_name'];

file_put_contents($img, file_get_contents($url));

使用卷曲

$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => $_FILES["image"]["tmp_name"]));

curl_setopt($ch, CURLOPT_URL, '`http://198.164.241.108/~bss/api/images/upload_images`');

curl_exec($ch);
curl_close($ch);

但是这两个都不起作用

【问题讨论】:

标签: php


【解决方案1】:

据我了解,它是远程服务器,因此您必须连接到该服务器并使用ftp_put()。此外,要使用 $_FILES 全局变量,您需要先使用一些 HTML 表单(我希望您在问题中跳过了这个明显的部分)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-16
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    相关资源
    最近更新 更多