Jump to content

Multiple Audio file upload


shubh2488

Recommended Posts

Hello i need help,

 

I am creating a small social networking website in which i want dat a user can upload music files as well with some descriptions ,the description and file path should be stored in database and the mp3 file should be stored in a seprate folder i want a PHP script for this.

 

If any one knows it then please help me.

Link to comment
https://forums.phpfreaks.com/topic/252035-multiple-audio-file-upload/
Share on other sites

Post your code and the problems you're having. Include any error messages, also.

 

<?php
if(isset($_POST))
{
    if(is_uploaded_file($_FILES['ufile']['tmp_name']))
    {
         // File is uploaded correctly
        if($_FILES['ufile']['type'] == 'audio/mpeg')
        {
            if(!move_uploaded_file($_FILES['ufile']['tmp_name'], '/upload/' . $_FILES['ufile']['filename']))
            {
               echo" File was moved successfully!";
            }
            else
            {
                echo" File was not moved successfully";
            }
        }
        else
        {
            // File is not of the audio/mpeg type
        } 
    }
    else
    {
    echo"File isn't uploaded correctly";
    }
}
else
{
    // Nothing posted, show the form
}  
?>

 

 

the output is "File isn't uploaded correctly"

At the beginning of the script, add the following, and post the output it generates after the form has been submitted.

 

echo '<pre>';
print_r($_POST);
echo '</pre><br><br><pre>';
print_r($_FILES);
echo '</pre>';


<?php
echo '<pre>';
print_r($_POST);
echo '</pre><br><br><pre>';
print_r($_FILES);
echo '</pre>';
if(isset($_POST))
{
    if(is_uploaded_file($_FILES['ufile']['tmp_name']))
    {
         // File is uploaded correctly
        if($_FILES['ufile']['type'] == 'audio/mpeg')
        {
            if(!move_uploaded_file($_FILES['ufile']['tmp_name'], '/upload/' . $_FILES['ufile']['filename']))
            {
               echo" File was moved successfully!";
            }
            else
            {
                echo" File was not moved successfully";
            }
        }
        else
        {
            // File is not of the audio/mpeg type
        } 
    }
    else
    {
    echo"File isn't uploaded correctly";
    }
}
else
{
    // Nothing posted, show the form
}  
	?>

 

 

i am attaching the jpeg image of my output hav a look

i choose mp3 file for uploading

 

[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.