简体   繁体   中英

Sending MP3 file to server

I have a problem. I'm writng a simple form for upload file to server. I can send any file without mp3, I don't know why. add2.php:

{
    $max_size = 104857600;
    if (is_uploaded_file($_FILES['plik']['tmp_name'])) {
        if ($_FILES['plik']['size'] > $max_size) {
            echo 'Error! File is too big!';
        } else {
            echo 'I have file, name: '.$_FILES['plik']['name'];
            $nazwa= $_FILES['plik']['name'];

            mysql_query("INSERT INTO files (name) values ('{$nazwa}') ");

            echo '<br/>';
            if (isset($_FILES['plik']['type'])) {
                echo 'Typ: '.$_FILES['plik']['type'].'<br/>';
            }

            move_uploaded_file($_FILES['plik']['tmp_name'],
            $_SERVER['DOCUMENT_ROOT'].'/music/'.$_FILES['plik']['name']);
        }
    } else {
        echo 'Error with sending file!';
    }

When i try to send mp3 i get "Error with sending file!".

EDIT:

<form action="add2.php" method="POST" ENCTYPE="multipart/form-data">
<input type="file" name="plik"/><br/>
<input type="submit" value="Send file"/>
</form>';

I tested on my machine and see:

Looks like your mp3 file cannot be uploaded, so it is missing in $_FILES array. That might be due to its size compared to image files.

Please check upload_max_filesize and post_max_size settings from your php.ini and allow a greater size than your mp3 file.

Font: How to upload mp3 files

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