从URL上传图像作为文件

Using this script "PHP and Jquery image upload and crop": http://www.webmotionuk.com/php-jquery-image-upload-and-crop/ I want to upload file not from local, but from URL. Any ideas how I must to do it?

I'm trying to do this like that

<form name="photo" action="test.php" method="post">
    <input type="hidden" name="zdj_tmp" value="E:\WebServ3\httpd\telebim\zdjecia\<? echo $select_zdjecie_2["id_4"]; ?>.jpg"/>
    <input type="hidden" name="zdj_name" value="<? echo $select_zdjecie_2["id_4"]; ?>.jpg"/>
    <input type="hidden" name="zdj_size" value="7340043"/>
    <input type="hidden" name="zdj_type" value="image/jpeg"/>               

    <input type="submit" name="upload" value="Upload" />
</form>

And than in php file

$userfile_name = $_POST['zdj_name'];
$userfile_tmp = $_POST['zdj_tmp'];
$userfile_size = $_POST['zdj_size'];
$userfile_type = $_POST['zdj_type'];

But it doesn't work.

Any ideas?

Try this.

<form action="test.php" method="POST">
  <input type="text" name="fileURL" placeholder="URL to image">
  <input type="submit" name="upload" value="Upload files"/>
</form>

Here is the PHP

//Get the file from the URL. 
$content = file_get_contents($_POST['fileURL']);

//Open the file that exists in your root already
$fp = fopen("/location/to/save/image.jpg", "w");

//Copy the information into the existing image
fwrite($fp, $content);
fclose($fp);

This takes the information from the image, and copies (overwrites) it into your existing image, which is, well, just some useless image.

You can then load the image from your roots.

It's not the best way, since your original image will be messed up, and is only usable once, since other users will change it, and there are other better ways. But if your site is a very not-popular kind of site, and you just want to test some methods out, this is definitely one kind of way. Just not the best.