Quantcast
Channel: User FoxInFlame - Stack Overflow
Viewing all articles
Browse latest Browse all 35

Answer by FoxInFlame for upload image as file from URL

$
0
0

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 imagefwrite($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.


Viewing all articles
Browse latest Browse all 35

Trending Articles