i have a function to upload file in php Like:
function upload_file($folder,$name)
{
$dest = "../product/". $folder."/". $name;
$src = $_FILES['image']['tmp_name'];
if (move_uploaded_file($src, $dest)) {
} else {
echo "<script> alert('" . $src . "');
window.history.go(-1); </script>\n";
exit();
}
}
whene i call function only one time like upload_file('small','abc.jpg') it works fine but
i have call two time like:
upload_file('small','abc.jpg')
upload_file('big','abc.jpg')
it not work on second folder ‘big’
any solution for that ?
move_uploaded_filehas moved to the first destination.So, the solution is get the first destination path, and copy with it for the other.
It will be a lot of solutions. One of them, change the param into array and iterate it.