php - incorrect filename iOS8 File Upload -
hello trying create simple multiple file uploader works on mobile devices. right testing on ios 8.
when upload file iphone 6 plus finding script not getting filename form when submitted. defaults image.jpg when uploading png. have been looking file api can't find i'm looking for. able change filename files upload without replacing each other @ least keep filename. help?
heres have code.
index.php
<html lang="en"> <head> <meta charset="utf-8" /> <title>multiple file upload php</title> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" id="file" name="files[]" accept="image/*"> <input type="submit" value="upload!" /> </form> </body> </html>
upload.php
<?php $valid_formats = array("jpg", "png"); $max_file_size = 1024*5000; $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 large 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.$count.'-'.$name )) $count++; // number of uploaded file } } } } ?>
Comments
Post a Comment