PHP通过url上传图像文件

San*_*asu -2 php image-upload

我想通过网址上传图片

'C:\wamp\www\reelstubs\app\webroot\img\movies\0bf522bb76777ba43393b9be5552b263.jpg'
Run Code Online (Sandbox Code Playgroud)

但我想要一个类似的阵列

array(
   'name' => '',
   'type' => '',
   'tmp_name' => '',
   'error' => (int) 4,
   'size' => (int) 0
),
Run Code Online (Sandbox Code Playgroud)

请建议我如何获得?

Jak*_*e N 11

也许你需要http://php.net/manual/en/function.file-get-contents.phphttp://php.net/manual/en/function.file-put-contents.php

结合在一起你可以尝试;

// Your file
$file = 'C:\wamp\www\reelstubs\app\webroot\img\movies\0bf522bb76777ba43393b9be5552b263.jpg';

// Open the file to get existing content
$data = file_get_contents($file);

// New file
$new = 'C:\wamp\www\reelstubs\app\webroot\img\movies\newimage.jpg';

// Write the contents back to a new file
file_put_contents($new, $data);
Run Code Online (Sandbox Code Playgroud)