views:

86

answers:

6

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);

    }

}
A: 
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).

Coronatus
no it is not working in this way also
Rajanikant shukla
Then you will need to give about 5000 times more detail. Turn on error reporting?
Coronatus
+5  A: 

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!

Nort
+1 Nice catch. Technically its a warning and he/she has those turned off. Probably.
zaf
A: 

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.

dhh
+1  A: 

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:

  • Directory has write permissions
  • You are specifying the correct path
  • Try your path like "./resume/".$filename
  • Try prefixing your path with $_SERVER['DOCUMENT_ROOT']
Sarfraz
A: 

the first element you have to check when doing upload is $filename["error"]

Col. Shrapnel
A: 

try using one of these: http://bit.ly/cTXQ75 | http://bit.ly/auxGqy | http://bit.ly/aEopoV

moustafa