简体   繁体   中英

Problem to upload audio file in php

Here is my code:

if ($_FILES['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.

我认为您想使用move_uploaded_file()而不是复制

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM