Multiple file uploads issue - php

I have a simple code to upload multiple images that uploads the image to a folder and saves the path to the database. The problem is I have 3 browse buttons. The script only uploads the files and saves the path to the database when all the three browse buttons are selected with images. But when I select only 1 image to upload the script does not works. What is the matter?
Here is my current script.
<?php
include'includes/db.php';
if(isset($_POST['submit'])){
$extension = substr($_FILES['photo1']['name'],
strrpos($_FILES['photo1']['name'], '.'));
$extension = substr($_FILES['photo2']['name'],
strrpos($_FILES['photo2']['name'], '.'));
$extension = substr($_FILES['photo3']['name'],
strrpos($_FILES['photo3']['name'], '.'));
$extension = strtolower($extension);
echo $extension;
if( $extension == ".jpg" || $extension == ".jpeg" || $extension == ".gif" || $extension == ".png" )
{
$img1=$_FILES['photo1']['name'];
$img2=$_FILES['photo2']['name'];
$img3=$_FILES['photo3']['name'];
$size=$_FILES['photo']['size'];
$type=$_FILES['photo']['type'];
$temp1=$_FILES['photo1']['tmp_name'];
$temp2=$_FILES['photo2']['tmp_name'];
$temp3=$_FILES['photo3']['tmp_name'];
$limit_size = 1024000;
$size_in_kb = 1024;
$max_size = $limit_size/$size_in_kb;
if($size > $limit_size)
{
echo "<script>location.replace('test.php?err=File size exceeds $max_size KB')</script>";
}
else
{
move_uploaded_file($temp1,"images/".$img1);
move_uploaded_file($temp2,"images/".$img2);
move_uploaded_file($temp3,"images/".$img3);
$sql2="INSERT INTO ad_images(image1, image2, image3)VALUES('$img1', '$img2', '$img3')";
$res2=mysql_query($sql2);
if($res2){
echo "<script>location.replace('test.php?success=Product added successfuly')</script>";
}else{
echo "<script>location.replace('test.php?vlx=Error. Try Again...')</script>";
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Script Testing</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<p> Upload Image<br />
<input type="file" name="photo1" id="photo"><br />
<input type="file" name="photo2" id="photo"><br />
<input type="file" name="photo3" id="photo"><br />
<input type="submit" name="submit" id="submit" value="Add Product" style="margin-top: 25px; margin-left: 335px;"/>
</p>
</body>
</html>
I don't get whats wrong in my code everything seems to be fine. Please help.
************ SOLVED ***************
I was using the same variable extension. Now solved.
Here is my new code.
<?php
include'includes/db.php';
if(isset($_POST['submit'])){
$extension1 = substr($_FILES['photo1']['name'],
strrpos($_FILES['photo1']['name'], '.'));
$extension2 = substr($_FILES['photo2']['name'],
strrpos($_FILES['photo2']['name'], '.'));
$extension3 = substr($_FILES['photo3']['name'],
strrpos($_FILES['photo3']['name'], '.'));
$extension1 = strtolower($extension1);
echo $extension1;
$extension2 = strtolower($extension2);
echo $extension2;
$extension3 = strtolower($extension3);
echo $extension3;
if( $extension1 == ".jpg" || $extension1 == ".jpeg" || $extension1 == ".gif" || $extension1 == ".png" ||
$extension2 == ".jpg" || $extension2 == ".jpeg" || $extension2 == ".gif" || $extension2 == ".png" ||
$extension3 == ".jpg" || $extension3 == ".jpeg" || $extension3 == ".gif" || $extension3 == ".png" )
{
$img1=$_FILES['photo1']['name'];
$img2=$_FILES['photo2']['name'];
$img3=$_FILES['photo3']['name'];
$size=$_FILES['photo']['size'];
$type=$_FILES['photo']['type'];
$temp1=$_FILES['photo1']['tmp_name'];
$temp2=$_FILES['photo2']['tmp_name'];
$temp3=$_FILES['photo3']['tmp_name'];
$limit_size = 1024000;
$size_in_kb = 1024;
$max_size = $limit_size/$size_in_kb;
if($size > $limit_size)
{
echo "<script>location.replace('test.php?err=File size exceeds $max_size KB')</script>";
}
else
{
move_uploaded_file($temp1,"images/".$img1);
move_uploaded_file($temp2,"images/".$img2);
move_uploaded_file($temp3,"images/".$img3);
$sql2="INSERT INTO ad_images(image1, image2, image3)VALUES('$img1', '$img2', '$img3')";
$res2=mysql_query($sql2);
if($res2){
echo "<script>location.replace('test.php?success=Product added successfuly')</script>";
}else{
echo "<script>location.replace('test.php?vlx=Error. Try Again...')</script>";
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Script Testing</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<p> Upload Image<br />
<input type="file" name="photo1" id="photo"><br />
<input type="file" name="photo2" id="photo"><br />
<input type="file" name="photo3" id="photo"><br />
<input type="submit" name="submit" id="submit" value="Add Product" style="margin-top: 25px; margin-left: 335px;"/>
</p>
</body>
</html>

because u take the same variable $extension and if the third browse field will not be choosen , after submit it will be blank and it will not entered into the upload if condition. If u will browse only from third browse button then that single file will be uploaded.

You can use multiple attribute to upload multiple files throw a single browse button eg
<input type="file" name="img" multiple>
You can use ctrl to select multiple images

Related

uploading zip files with PHP, undefined index

I'm having issues uploading zip files and can't seem to find an answer.
Index.php
<form id="convertFile" action="convert.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input name="upload" type="file" id="inputFile">
</div>
<div class="form-group">
<button type="submit">Submit</button>
</div>
</form>
convert.php:
if(isset($_FILES)){
echo $_FILES['upload']['name'];
}else{
echo json_encode(array('status'=>'error'));
}
When I upload a zip file, I get: Notice: Undefined index: upload in C:\wamp\www\xmlconverter\convert.php on line 3
This is what chrome shows in the post header:
------WebKitFormBoundaryuFNy5dZtFj7olmD5
Content-Disposition: form-data; name="zip_file"; filename="123.zip"
Content-Type: application/x-zip-compressed
------WebKitFormBoundaryuFNy5dZtFj7olmD5--
This works on any other major file format, but can't get it to read the zip file. If I var_dump $_FILES or $_POST they are empty.
What am I missing? Why does all other files work but zip does not.
Thank you
using wamp and php 5.5.12
Where is your zip file type definition?
Anyways, let say this was the html form to upload zip files you'd have the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php if($message) echo "<p>$message</p>"; ?>
<form enctype="multipart/form-data" method="post" action="">
<label>Choose a zip file to upload: <input type="file" name="zip_file" /></label>
<br />
<input type="submit" name="submit" value="Upload" />
</form>
</body>
</html>
On the server-side script which handles the post you'd have:
<?php
if($_FILES["zip_file"]["name"]) {
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
}
}
$continue = strtolower($name[1]) == 'zip' ? true : false;
if(!$continue) {
$message = "The file you are trying to upload is not a .zip file. Please try again.";
}
$target_path = "/home/var/yoursite/httpdocs/".$filename; // change this to the correct site path
if(move_uploaded_file($source, $target_path)) {
//if you also wanted to extract the file after upload
//you can do the following
$zip = new ZipArchive();
$x = $zip->open($target_path);
if ($x === true) {
$zip->extractTo("/home/var/yoursite/httpdocs/"); // change this to the correct site path
$zip->close();
unlink($target_path);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
}
?>
I used a script very similar to one posted by #unixmiah without issue on my cPanel based server. Worked great (and has for year now) but ran into issue of error "PHP, undefined index" when using locally with wamp.
Here is the mod that worked for me:
<?php
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
else unlink("$dir/$file");
}
rmdir($dir);
}
if(!empty($_FILES)){
//added above to script and closing } at bottom
if($_FILES["zip_file"]["name"]) {
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
}
}
$continue = strtolower($name[1]) == 'zip' ? true : false;
if(!$continue) {
$message = "<b>The file you are trying to upload is not a .zip file! Please try again...</b>";
}
$target_path = "somedir/somesubdir/".$filename; // change this to the correct site path
if(move_uploaded_file($source, $target_path)) {
$zip = new ZipArchive();
$x = $zip->open($target_path);
if ($x === true) {
$zip->extractTo("somedir/somesubdir/"); // change this to the correct site path
$zip->close();
unlink($target_path);
}
$message = "<h2>ZIP file was uploaded and content was replaced!</h2>";
} else {
$message = "There was a problem with the upload. Please try again.";
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>QikSoft ZIP Upper</title>
</head>
<body>
<?php if(!empty($message)) echo "<p>$message</p>"; ?>
<form enctype="multipart/form-data" method="post" action="">
<label><h3>Upload Your ZIP:</h3> <input type="file" name="zip_file" /></label>
<br /><br />
<input type="submit" name="submit" value="START UPLOAD" />
</form>
</body>
</html>
Also note that the echo message has been changed:
<?php if(!empty($message)) echo "<p>$message</p>"; ?>
One thing that does not work is file restriction. Currently allows other types besides ZIP. Anyone with fix, be greatly appreciated.
It's echo $_FILES['upload']['tmp_name'];
Try checking and adjusting the post_max_size value in your php.ini file, this worked for me as the default is 3M, raised the value to 128M and everything was peachy

Multiple Image insert taking extra one row after each insert

Here I am using this php code for insert multiple images in one field in database table but after insert a row is taking one extra row after each insert .......Help me to solve this issue..
Thank you Advance.
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
/*if(isset($_REQUEST['submit']))
{
$pname=$_FILES['image']['name'];
$tmp_name=$_FILES['image']['tmp_name'];
move_uploaded_file($tmp_name."photo/".$pname);
$fileext = pathinfo($pname, "photo/");
$fileext = strtolower($fileext);
}*/
$uploads_dir = 'photo/';
//$images_name ="";
foreach ($_FILES["image"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["image"]["tmp_name"][$key];
$name = $_FILES["image"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
$images_name =$images_name.$name.",";
}
}
$sql=mysql_query("INSERT INTO multiimg(image) values('".$images_name."')");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function addmore(num)
{
if(num==1)
{
document.getElementById('field2').style.display='block';
document.getElementById('ni1').style.display='block';
return false;
}
else if(num==2)
{
document.getElementById('field3').style.display='block';
return false;
}
}
</script>
</head>
<body>
<form enctype="multipart/form-data" name="" action="" method="post">
<div id="field1">Enter One Image :<input type="file" name="image[]" id="img1"/>addmore...</div>
<div id="field2" style="display:none;">Enter Two Image :<input type="file" name="image[]" id="img2"/>add more...</div>
<div id="field3" style="display:none;">Enter Three Image :<input type="file" name="image[]" id="img3"/>addmore...</div>
<div id="field4" style="display:none">Enter Forth Image :<input type="file" name="image[]" id="img4"/>addmore...</div>
<input type="submit" name="submit"/>
</form>
</body>
</html>
please check if the form is posted then do the insert ,else while loading the page a row will be inserted in table with empty data
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
if(isset($_POST['submit'])){
$uploads_dir = 'photo/';
//$images_name ="";
foreach ($_FILES["image"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["image"]["tmp_name"][$key];
$name = $_FILES["image"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
$images_name =$images_name.$name.",";
}
}
$sql=mysql_query("INSERT INTO multiimg(image) values('".$images_name."')");
}
?>

Uploaded images not in image folder

I just made a file upload code and I was wondering why the file upload wasn't working? I checked the permission of my image folder in localhost and that seems to be ok. I don't know where the problem exactly is. Any ideas?
<?php
require "config.php";
require "functions.php";
require "database.php";
if(isset($_FILES['fupload'])){
$filename = addslashes($_FILES['fupload']['name']);
$source = $_FILES['fupload']['tmp_name'];
$target = $path_to_image_directory . $filename;
$description = addslashes($_POST['description']);
$src = $path_to_image_directory . $filename;
$tn_src = $path_to_thumbs_directory . $filename;
if (strlen($_POST['description'])<4)
$error['description'] = '<p class="alert">Please enter a description for your photo</p>';
if($filename == '' || !preg_match('/[.](jpg)|(gif)|(png)|(jpeg)$/', $filename))
$error['no_file'] = '<p class="alert">Please select an image, dummy! </p>';
if (!isset($error)){
move_uploaded_file($source, $target);
$q = "INSERT into photo(description, src, tn_src)VALUES('$description', '$src','$tn_src')";
$result = $mysqli->query($q) or die (mysqli_error($myqli));
if ($result) {
echo "Succes! Your file has been uploaded";
}
createThumbnail($filename);
}
}
?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Upload</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>My photos</h1>
<ul><?php getPhotos(); ?></ul>
<h2>Upload a photo</h2>
<form enctype="multipart/form-data" action="index.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="file" name="fupload" /><br/>
<textarea name="description" id="description" cols="50" rows="6"></textarea><br/>
<input type="submit" value="Upload photo" name="submit" />
</form>
<?php
if (isset($error["description"])) {
echo $error["description"];
}
if (isset($error["no_file"])) {
echo $error["no_file"];
}
?>
</body>
</html>
Please make sure that you appended directory separator in $path_to_thumbs_directory.
And you don't need to use addslashes to $filename.

on upload get all file names in array in php

What i want to know is how can I get a list [specifically array] of all the files name in a directory when I select it through upload button, after which I would upload that array of files to the database. As one file as a single entry. So how do I do that?
No to forget that I just need files names and I have to upload these names only not the actual files.
are the files on the server? if you hopping to have a button you click on browser and open a folder on the end user this will not work. most browsers only allow single file selection
If you are using ftp, this function will return all of the filenames of a directory in an array.
function ftp_searchdir($conn_id, $dir) {
if(!#ftp_is_dir($conn_id, $dir)) {
die('No such directory on the ftp-server');
}
if(strrchr($dir, '/') != '/') {
$dir = $dir.'/';
}
$dirlist[0] = $dir;
$list = ftp_nlist($conn_id, $dir);
foreach($list as $path) {
$path = './'.$path;
if($path != $dir.'.' && $path != $dir.'..') {
if(ftp_is_dir($conn_id, $path)) {
$temp = ftp_searchdir($conn_id, ($path), 1);
$dirlist = array_merge($dirlist, $temp);
}
else {
$dirlist[] = $path;
}
}
}
ftp_chdir($conn_id, '/../');
return $dirlist;
}
<?
if (isset($_POST[submit])) {
$uploadArray= array();
$uploadArray[] = $_POST['uploadedfile'];
$uploadArray[] = $_POST['uploadedfile2'];
$uploadArray[] = $_POST['uploadedfile3'];
foreach($uploadArray as $file) {
$target_path = "upload/";
$target_path = $target_path . basename( $_FILES['$file']['name']);
if(move_uploaded_file($_FILES['$file']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['$file']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload-simple.php" method="POST">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload:
<input name="uploadedfile" type="file" />
</p>
<p>Choose a file to upload:
<input name="uploadedfile2" type="file" />
</p>
<p>Choose a file to upload:
<input name="uploadedfile3" type="file" />
<input name="submit" type="submit" id="submit" value="submit" />
</p>
</form>
</body>
</html>
This Might be Solve your Problems
If the files already exist on the server you can use glob
$files = glob('*.ext'); // or *.* for all files
foreach($files AS $file){
// $file is the name of the file
}

single image to multiple image upload

I have the follow script that uploads and image and a thumbnail to a directory and store the img names (img and thumb) to the database.
I originally found this script somewhere on the web while googling but, but now I need to be able to upload more than one image... it works fine for one image as is.
<?php
//error_reporting(0);
$change="";
$abc="";
define ("MAX_SIZE","400");
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image =$_FILES["file"]["name"];
$uploadedfile = $_FILES['file']['tmp_name'];
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
$change='<div class="msgdiv">Unknown Image extension </div> ';
$errors=1;
}
else
{
$size=filesize($_FILES['file']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
$change='<div class="msgdiv">You have exceeded the size limit!</div> ';
$errors=1;
}
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
echo $scr;
list($width,$height)=getimagesize($uploadedfile);
$newwidth=60;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
$newwidth1=25;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
$filename = "images/". $_FILES['file']['name'];
$filename1 = "images/small". $_FILES['file']['name'];
imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}}
}
//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors)
{
mysql_query("INSERT INTO `imgs` (`id` ,`user_id` ,`img_name`) VALUES (NULL , '$userID', 'img1.jpg');");
$change=' <div class="msgdiv">Image Uploaded Successfully!</div>';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="en-us" http-equiv="Content-Language">
</head><body>
<?php echo $change; ?>
<div id="posts">
<form method="post" action="" enctype="multipart/form-data" name="form1">
<input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/>
<input type="submit" id="mybut" value="Upload" name="Submit"/>
</form>
</div>
</body></html>
for multiple image I know I can change the html portion to a foreach loop, like:
<form method="post" action="" enctype="multipart/form-data" name="form1">
<?php
$allow_upload = 10;
for($i=0; $i<$allow_upload; $i++) {
echo '<input size="25" name="file[]" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/>';
}
?>
<input type="submit" id="mybut" value="Upload" name="Submit"/>
</form>
but I havent been able to figure how and where to put a foreach loop and and adapty the rest for multiple images.
my db setup would be something like id, userID, big img, small img.
any help would be greatly appreciated, im ready to start pulling my hair out!!
if you want to loop multiple file input elements then you need to tell that it is an array unless you have a different name for each input elements.
for($i=0; $i<$allow_upload; $i++) {
echo '<input size="25" name="file[]" type="file"'/>;
}
if you want to select multiple file from one input element then
<input name="filesToUpload[]" type="file" multiple/>
Instead of multiple input files you can use a single input file and save all the files in array, and use foreach to save each file to folder.
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
foreach($_FILES['allimages'] as $files) {
var_dump($files);
}
}
?>
<form id="fileupload" enctype="multipart/form-data" method="post">
<input type="file" name="allimages[]" id="allimages" multiple><!--Use CTRL key to upload multiple images -->
<input type="submit" name="submit" id="submit">
</form>
you need to hold cntrl key to upload multiple files.

Categories