开发者

file upload with php

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"];
    $开发者_如何学Pythonfilename=$filename['name']; 
    $filetempname=$filename['tmp_name'];
    if($filetype=="application/msword")
    {
        move_uploaded_file($filetempname,"resume/".$filename);

    }

}


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!


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


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜