Reputation: 21
Hi every body I am uploading file with php every thing is fine but move_uploded_file is not working every variable displayed record and all permission for file is set
function uploadfile($filename)
{
$filetype=$filename["type"];
$filename=$filename['name'];
$filetempname=$filename['tmp_name'];
if($filetype=="application/msword")
{
move_uploaded_file($filetempname,"resume/".$filename);
}
}
Upvotes: 2
Views: 225
Reputation: 157981
the first element you have to check when doing upload is $filename["error"]
Upvotes: 0
Reputation: 382861
First of all set error reporting on, on top of your script put this:
ini_set('display_errors', true);
error_reporting(E_ALL);
Then make sure that file type is really application/msword
echo $filetype;
And make sure that the path is correct:
echo "resume/".$filename;
Also make sure that:
"./resume/".$filename
$_SERVER['DOCUMENT_ROOT']
Upvotes: 1
Reputation: 4335
Try setting display_errors = on, then you'll get error messages ;-) Or output some message in the else statement to see wether the if-condition didn't match.
Upvotes: 0
Reputation: 2041
The $filename
array, turns into a string at this line: $filename=$filename['name'];
I'm wondering why you didn't get an error message.
Try an other var name instead of $filename as a function parameter and i'm sure it will work!
Upvotes: 5
Reputation: 17977
if($filetype=="application/msword")
That line won't work, because it is almost guaranteed the browser won't try to detect the file mime type. Take the if
statement out and it should work.
You should still try to validate the file in a different way (and absolutely make sure it is not PHP, cause that would be a huge security vulnerability).
Upvotes: 0