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
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.)
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>
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>
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).
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.