Hey guys, I am trying to write a script that will let me upload a file selected from a directory on my computer using PHP. I want to browse my PC and select a file which I can do, but when I select upload I get this error:
PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
I think it may because I cannot create a temporary file on my server or my temp folder location is not the default? I looked at phpinfo on my server, which is a university server, and i saw that upload_tmp_dir was F:\Temp
Can I set my uploads to find this folder? I have a created a folder called uploaded which is where the final file needs to go, but I just cant get it to work. Any suggestions?
Here is my form:
<form enctype="multipart/form-data" action="ul.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
And here is the action script:
<?php// Where the file is going to be placed
$target_path = "uploaded/";
$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!";
}
?>
Thanks!