PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if($_POST['Submit']) {
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
} }
I'd like to change filename when the file is uploaded to a predefined variable.
How do I do this? I think the tmp_name needs to change somehow but I have no clue how...
if($_FILES[picture_1][name] !="") {
$image_name = $_FILES[picture_1][name] ;
$extension = ".jpg";
$newimg_Name = "$m_id" . $extension; // m_id is defined before this snippet
$newimg_Path = "modules/uploads/" . $newimg_Name;
move_uploaded_file($_FILES[picture_1][tmp_name], $newimg_Path);
chmod($newimg_Path, 0777);
}
And it works!
But an additional question,
is it possible to upload if to 2 different locations at once?
adding a move_uploaded_file doesn't work.. also adding the entire code again with a new $newimg_Path
Keeps giving me "Error. Couldn't copy that file".
Is the way I set the new path correctly?
I had a look at rename() but that removes the original picture from the directory too.
Maybe first a