Jump to content

problem uploading files:


chelnov63

Recommended Posts

Hi everyone this is a snippet of my code in a page to which form values are posted to. The form includes two file fields - one for uploading an image and one for uploading a music file..however only ONE manages to get uploaded..if i comment out the 'image code' then the music file is uploaded fine ..and if i comment out the music code then only the image file is uploaded... why will it not upload both together to their respective folders? it seems it will only upload one or the other but not both at the same time ...thanks in advance for your help:

 

if (is_uploaded_file($_FILES['image_source']['tmp_name']))
{
       echo "put in image";
$uploadDirectory = "../../images/audio/";
$uploadFile = $uploadDirectory.basename("image_".$random.".jpg");
move_uploaded_file($_FILES['image_source']['tmp_name'], $uploadFile);
}

  
if (is_uploaded_file($_FILES['music_source']['tmp_name']))
{
        echo "put in music";
$uploadDirectory = "../../music/";
$uploadFile = $uploadDirectory.basename("music_".$random.".mp3");
move_uploaded_file($_FILES['music_source']['tmp_name'], $uploadFile);
}


Link to comment
https://forums.phpfreaks.com/topic/117148-problem-uploading-files/
Share on other sites

Paste us in the HTML Code for your Form

 

Make sure it has the

<form method="post" enctype="multipart/form-data" action="yourphpfile.php" >  

 

Also make sure that the Form Fields pair to the $_FILES['music_source']

 

Basically meaning that the box that uploads the Music Files is called "music_source"

 

hi thanks for that but the form field names etc are all correct ... as i mentioned .. if I comment out the image block of code then the music file will upload and if I comment out the music block of code then the image file will upload...

 

its just if both are UNCOMMENTED then only the image file will upload then...

 

thanks

Edit: you need to show specifically what you are commenting out.

 

You don't state or show what or exactly how you are commenting out part of the upload code, but my guess is that combined, the files exceed one or more of the upload size settings.

 

Add the following code as a test -

 

echo "<pre>";
echo "POST:";
print_r($_POST);
echo "FILES:";
print_r($_FILES);
echo "</pre>";

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.