upload batch of files

Discussion in 'PHP' started by mehdiali, Jul 17, 2008.

  1. #1
    Hi everyone
    i want to create an uploader that can upload some files
    for each time(not one by one).
    what can i do?
    can i write a class that get some files(in client) and contact them to one file
    after that in server divide it to origin files?
    plz don't send code. explain your methode.
    thankyou all
     
    mehdiali, Jul 17, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    I had to read your message like 5 times until I understood what you're trying to do. (At least I think I understand now.)

    Anyway, what you're trying to do is not possible with PHP (nor Javascript). PHP is on the server, and has absolutely no access to the browser or even the client's computer. So there's no way it can join/merge files.

    If that's possible at all, you'll need a client side program, which the user would have to download to his computer first. (And again, it shouldn't be written in PHP, since most people don't have the possibility to run PHP scripts on their machine.)
     
    nico_swd, Jul 17, 2008 IP
  3. metalik

    metalik Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Uploading multiple files
    <form action="file-upload.php" method="post" enctype="multipart/form-data">
    Send these files:<br />
    <input name="userfile[]" type="file" /><br />
    <input name="userfile[]" type="file" /><br />
    <input name="userfile[]" type="file" /><br />
    <input name="userfile[]" type="file" /><br />
    <input type="submit" value="Send files" />
    </form>
     
    metalik, Jul 17, 2008 IP
  4. sastro

    sastro Well-Known Member

    Messages:
    214
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Try this

    <?php
    $numuploads = 5;
    $updir='files';

    if(isset($_POST['submit'])){
    $numfilesuploaded = $_POST['numuploads'];
    $count = 1;

    while ($count <= $numfilesuploaded)
    {
    $conname = "new_file".$count;

    $filetype = $_FILES[$conname]['type'];

    $filename = $_FILES[$conname]['name'];
    if ($filename != '')
    {

    $maxfilesize = $_POST['maxsize'];
    $filesize = $_FILES[$conname]['size'];
    if($filesize <= $maxfilesize )
    {
    $randomdigit = rand(0000,9999);

    $newfilename = $randomdigit.$filename;
    $source = $_FILES[$conname]['tmp_name'];
    $target = "$updir/".$newfilename;
    move_uploaded_file($source, $target);
    echo $count." File uploaded | ";


    }
    else
    {
    echo $count." File is too big! 10MB limit! |";

    }

    }
    $count = $count + 1;
    }

    }
    $count = 1;
    ?>
    <html>
    <form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
    <?php
    while ($count <= $numuploads)
    {

    ?>
    <input name="new_file<?php echo $count; ?>" id="new_file<?php echo $count; ?>" size="30" type="file" class="fileUpload" /><br>
    <?php
    $count = $count + 1;
    }
    ?>
    <input type = "hidden" name="maxsize" value = "10240000">
    <input type = "hidden" name="numuploads" value = "<?php echo $numuploads; ?>">
    <br>
    <button name="submit" type="submit" class="submitButton">Upload Files</button>

    </form>
    </html>
     
    sastro, Jul 17, 2008 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Maybe I misunderstood him, but I think he wants to join/merge multiple files on the client's computer and upload them as one. Then use PHP to separate the files again. If that's the case, it's not impossible, but a bit hard (and not user friendly).
     
    nico_swd, Jul 17, 2008 IP
  6. mehdiali

    mehdiali Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thankyou all...
    you are admin of an image gallery and want to upload 200 images.
    you can't upload all of them one by one so need to upload batch of files.
    my idea :
    because access to clients(admin) machine are limited so i think
    it is impossible to upload files aoutomatically
    and so the solution is just uploadind a zip file.
     
    mehdiali, Jul 17, 2008 IP
  7. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I sent you a pm with a download link
     
    scriptglue, Jul 18, 2008 IP