This is a great and useful code, but it still needs some improvements:
If you enter a wrong URL, the following error will be dispalyed:
- Code: Select all
Warning: copy(hh): failed to open stream: No such file or directory in /home/****/inc/mod/images.mdu on line 550
File upload failed.
I changed the code a bit which now solves the above warning:
- Code: Select all
<?php
if ($_GET[loadurl]){
$from = $_POST[from];
if (!is_array(@getimagesize($from)))
{
echo 'Failed to open the URL.';
} else{
if($_POST[to] == "") {
$to = basename("$from");
} else $to = $_POST[to];
if (!copy("$_POST[from]","$folder/$to")){
echo 'File upload failed.';
}
}
}
?>
It also automatically overwrites if a file already exists, this can cause a big problem.
Also it should check to upload only image files (jpg, png, gif) and stop upload of any other kind of images.