php - Multifile upload -
looking next solutions:
form html / php provide ability add together multiple graphic files (up 11 files, max 5mb).
when sending server script should following:
check if file has extension (jpg, png); re-name each file according formula < string 32 characters > _ < 000 010 >. < extension >; add file names table (one file = 1 column, row); compress maximum resolution of 1280x1024; change proportions of graphics on 4: 3 images while maintaining same proportions; lessen size of file , save server in appropriate folder.i'm interested in perchance easy utilize solution.thank much help.
try it,
html code
<html lang="en"> <head> <meta charset="utf-8" /> <title>multiple file ppload php</title> </head> <body> <form action="" method="post" enctype="multipart/form-data"> <input type="file" id="file" name="files[]" multiple="multiple" accept="image/*" /> <input type="submit" value="upload!" /> </form> </body> </html>
php code
<?php $valid_formats = array("jpg", "png"); $max_file_size = 1280*1024; $path = "uploads/"; // upload directory $count = 0; if(isset($_post) , $_server['request_method'] == "post"){ // loop $_files exeicute files foreach ($_files['files']['name'] $f => $name) { if ($_files['files']['error'][$f] == 4) { continue; // skip file if error found } if ($_files['files']['error'][$f] == 0) { if ($_files['files']['size'][$f] > $max_file_size) { $message[] = "$name large!."; continue; // skip big files } elseif( ! in_array(pathinfo($name, pathinfo_extension), $valid_formats) ){ $message[] = "$name not valid format"; continue; // skip invalid file formats } else{ // no error found! move uploaded files if(move_uploaded_file($_files["files"]["tmp_name"][$f], $path.$name)) $count++; // number of uploaded file } } } } ?>
php mysql
No comments:
Post a Comment