开发者

Problem to upload audio file in php

Here is my code:

if ($_FIL开发者_高级运维ES['music']['name'] != '')
{
    $file_name = time() . $_FILES['music']['name'];
    copy($_FILES['music']['tmp_name'], "music/" . $file_name); 
}    
else
{
    $file_name = "";
}

I want to upload audio file. the file name is insert into database. but its not insert into folder.


try move_uploaded_file instead. You may want to check file size limits too.


I think you want to use move_uploaded_file(), not copy


I guess the folder in which you are trying to copy the uploaded file is not the one you expect. Possibly this is what you need:

copy($_FILES['music']['tmp_name'], __DIR__ . "/music/" . $file_name); 

By the way move_uploaded_file() works faster and safer than copy().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜