The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 5 of 5

Thread: Multiple File Upload not working...

  1. #1

    Multiple File Upload not working...

    I am working on a form that takes some text inputs and two files.

    1 file is an image, and the other is an .mp3


    The script works fine up to uploading the Image file... but it doesn't upload the .mp3 any idea what I'm doing wrong?

    FORM (simplified):
    Code:
    <form id="performer" name="performer" action="add.php" method="post" enctype="multipart/form-data">
    
    <input id="image" name="ufile[]" type="file" />
    <input id="music" name="ufile[]" type="file" />
    
    <input type="submit" name="submit" value="Upload" />
    </form>
    UPLOAD SCRIPT:
    PHP Code:
        //set the different directories
        
    $image_dir '../../info/images/';
        
    $music_dir '../../info/music/';

        
    //set $image / $music to file destination
        //set $image_tmp / $music_tmp to file's upload name
        
    $image_name basename($HTTP_POST_FILES['ufile']['name'][0]);
        
    $image_tmp $HTTP_POST_FILES['ufile']['tmp_name'][0];
        
    $image $image_dir basename($HTTP_POST_FILES['ufile']['name'][0]);
        
    $music_name basename($HTTP_POST_FILES['ufile']['name'][1]);
        
    $music_tmp $HTTP_POST_FILES['ufile']['tmp_name'][1];
        
    $music $music_dir basename($HTTP_POST_FILES['ufile']['name'][1]);

       
    //move image to its destination
       
    copy($image_tmp$image)

       
    //move music to its destination
       
    copy($music_tmp$music
    the PHP script above was simplified A LOT but i know the problem lies somewhere in the lines posted and not in the ones I took out (like the extension checks) because If there is no file or the extension is wrong it wont even attempt to upload the file thus I would get a custom error message instead of the one I am getting.

    The error i'm getting refers to the variable $music_tmp where it is on the LAST LINE above.

    ERROR:
    Code:
    An error occurred in script '/home2/stillfri/public_html/stevefest/admin/band/add.php' on line 107: copy() [function.copy]: Filename cannot be empty Array
    I know the file is being uploaded because I test for a .mp3 extension on the $HTTP_POST_FILES['ufile']['name'][1] array and the test returns that it is an .mp3 extension....

    which means at least the file name is getting to the server...

    I don't know... does anyone have any ideas. I've read like 20 different multiple file upload tutorials and my syntax matches the ones in the tuts (so don't bother linking me to any tutorials please and thanks)

    Twitter / The Human Conditions

    biznuge: "that doesn't grammatical sense..."

  2. #2
    since you're not using a dynamic amount of uploads, why not use seperate fieldnames? have you tried that?

    You can never underestimate the stupidity of the general public.

  3. #3
    wow I feel like a retard.

    I found the problem... and i'm wondering why no-one suggested checking it...

    you know the "upload_max_filesize" setting in the 'php.ini' file

    the setting i didn't even know exhisted....



    yah it's fixed now.

    So if anyone else has this problem check the 'upload_max_filesize' in 'php.ini' and change it to what you need.

    Thanks for replying RVGate





    I feel like a complete noob... oh wait....... yah i am.. self taught PHP and database programmer.. go me

    Twitter / The Human Conditions

    biznuge: "that doesn't grammatical sense..."

  4. #4
    Quote Originally Posted by birdwing View Post
    self taught PHP and database programmer.. go me
    no excuse
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  5. #5
    Quote Originally Posted by simplistik View Post
    no excuse
    Not an excuse.. just simply stating my fail.
    Since this became such an issue I am actually doing more research into the php.ini file and what it controls.

    I simply never thought to look into it before as none of the books I read actually discussed it in detail.



    The only way I learn is through mistakes hence the "self taught PHP database programmer" thing....

    If your self taught that pretty much translates too...

    YAY! another problem once i figure out the solution i will learn something new

    Twitter / The Human Conditions

    biznuge: "that doesn't grammatical sense..."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012