android6011 Posted March 21, 2007 Share Posted March 21, 2007 I want the user to submit a url, say http://somesite.com/new.jpg and the script to save the image to the server. I dont want to do uploading on the user end. I have the form and everything set up I just need to know what to do with the url. thanks Link to comment https://forums.phpfreaks.com/topic/43588-save-file-to-server-from-url/ Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 I am not sure if http://us2.php.net/manual/en/function.readfile.php would work, if it does work it would be done something like this: <?php $url = "http://www.somesite.com/new.jpg"; ob_start(); readfile($url); $file = ob_get_contents(); ob_end_clean(); $fp = fopen('newfile.jpg', 'wb'); fwrite($fp, $file); fclose($fp); ?> I think you need the b there for binary, not sure. http://us2.php.net/manual/en/function.fopen.php for reference. Link to comment https://forums.phpfreaks.com/topic/43588-save-file-to-server-from-url/#findComment-211696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.