Uploading a file using php
Hello everyone, I am uploading a file from php everything is fine, but move_uploded_file is not working every variable displayed record and all file permissions are set
function uploadfile($filename)
{
$filetype=$filename["type"];
$filename=$filename['name'];
$filetempname=$filename['tmp_name'];
if($filetype=="application/msword")
{
move_uploaded_file($filetempname,"resume/".$filename);
}
}
+2
a source to share
5 answers
First of all install error reporting, on top of the script put this:
ini_set('display_errors', true);
error_reporting(E_ALL);
Then make sure the file type is indeed application/msword
echo $filetype;
And make sure the path is correct:
echo "resume/".$filename;
Also make sure that:
- The directory has write permissions.
- You point the right way
- Try your way like
"./resume/".$filename
- Try to prefix your path with
$_SERVER['DOCUMENT_ROOT']
+1
a source to share
if($filetype=="application/msword")
This line won't work because it's almost guaranteed that the browser won't try to determine the type of the mime file. Take a manual if
and it should work.
You should still try to validate the file differently (and absolutely make sure it is not PHP, because that would be a huge security vulnerability).
0
a source to share