Omdøbe oploaded fil til server i php
Forsøger at omdøbe fil, men får bare flad fil og ikke et jpg. gemt på server.Her er min Form:
echo "<form enctype=\"multipart/form-data\" action=\"http://servcer/administrator/userpic.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1024000\" />";
echo "Vælg dit billede: ";
echo "<input name=\"uploadedfile\" type=\"file\" />";
echo "<input name=\"usr_id\" value=\"$usr_id\" type=\"text\" />";
echo "<br />";
echo "<input type=\"submit\" value=\"Opload billede\" />";
echo "</form>";
Min php
<?php
$newname = ($_POST['usr_id']);
$file_name = $HTTP_POST_FILES['uploadedfile']['name'];
$new_file_name = $newname;
$target_path = "../images/profilepics/".$new_file_name;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file $new_file_name has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>