2

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

    }

}
2
  • Please explain what happens, what error messages come up and what $filetempname contains. Commented May 15, 2010 at 10:44
  • 1
    Just a wild guess: the folder resume exists yes? But you specify a relative path, so does the folder exists where the script is executed? Commented May 15, 2010 at 11:03

5 Answers 5

5

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!

Sign up to request clarification or add additional context in comments.

1 Comment

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

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']

Comments

0
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).

1 Comment

Then you will need to give about 5000 times more detail. Turn on error reporting?
0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.