I have some pictures that are online, the images are simple http://domain.com/pic.jpg for example; there's an upload feature but that's for user upload the user won't upload, it's an auto upload. This mean I have the Urls on an array and I want that php auto upload those Urls photo into the server Any help!! Thanks
+4
A:
define('IMAGE_PATH', '/path/to/images');
foreach ($urlArray as $url) {
file_put_contents(IMAGE_PATH . "/" . basename($url), file_get_contents($url));
}
This would require that the user Apache is running under has write access to the IMAGE_PATH. Also, this might not be the exact solution in your case. You seem to be in need of a database to store these filenames, which then probably should be wearing ids instead of their original filenames.
jesper
2009-03-21 16:27:21
You should change the filename before storing or block script execution under IMAGE_PATH using .htaccess. Suppose someone will pass mydomain.com/my_evil_script.php as image URL.
lacop
2009-03-21 17:20:39