手动设置$ _FILES值?(尝试从URI上传并想使用现有代码)

use*_*017 5 php upload post file

我正在尝试将imageboard脚本添加到Kusaba X中,以便从远程位置上传文件

该类对$_FILES['imagefile']['name']和进行了大量检查$_FILES['imagefile']['size'],希望将它们重用于从远程URI上传文件。在upload.class.php我有一个变量,其中包含我要上传的图片的URI。我不想重写所有的内容,而要制作一堆if / elses或实际上复制该代码,是否在想是否有办法按原样使用它们?

尝试使用($ imgURI是文件的http://位置):

$_FILES['imagefile']['name'] = $imgURI;
Run Code Online (Sandbox Code Playgroud)

$imagefile_name = fopen($imgURI,"rb");
$_FILES['imagefile']['name'] = $imagefile_name;
Run Code Online (Sandbox Code Playgroud)

但没有运气。

我可以在上面运行所有检查的主变量上进行查找和替换,但是应该包含什么内容?

希望这个问题很清楚,因为我做了任何PHP已有一段时间了,所以我可能会遗漏一些明显的东西。谢谢您对此的任何想法/想法

Nic*_*dre 0

It's unlikely that the $_FILES array will support downloading a remote file. Try using curl to download the file to a temporary location and then specify that in $_FILES array.

使用 PHP 将远程文件下载到服务器