Upload multiple file in php first to make input type multiple using html
STEP 1 form enctype="mutipart/form-data"
STEP 2 Create a input type file and name in array format "multiselect[]" and multiple to multiple file
STEP 4 Upload file, $uploads_dir =your directory name, $name= File name to store in folder with that name, you can keep your random also
1.Whole code Create a Index.php
<?php
if(isset($_POST['Submit'])){ //upload
$uploads_dir = 'image/';
foreach ($_FILES["multifileselect"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["multifileselect"]["tmp_name"][$key];
$name = basename($_FILES["multifileselect"]["name"][$key]);
if (copy($tmp_name, "$uploads_dir/$name")){
echo "successfully =>". $name;
}else{
echo "Not Uploaded Files";
}
}
}
}?>
<html>
<head></head>
<body>
<form method="post" action="" name="frmact" enctype="multipart/form-data">
Upload File : <input type="file" id="multifileselect" name="multifileselect[]" multiple="multiple" style="margin-left:50px;" />
<input type="submit" name="Submit" value="submit" style="margin-left:50px;" />
</form>
</body>
</html>
STEP 1 form enctype="mutipart/form-data"
form method="post" action="" name="frmact" enctype="multipart/form-data">
STEP 2 Create a input type file and name in array format "multiselect[]" and multiple to multiple file
Upload File : <input type="file" id="multifileselect" name="multifileselect[]" multiple="multiple" style="margin-left:50px;" />
STEP 3 Get a file name and file value in php code
$tmp_name = $_FILES["multifileselect"]["tmp_name"][$key];
$name = basename($_FILES["multifileselect"]["name"][$key]);
STEP 4 Upload file, $uploads_dir =your directory name, $name= File name to store in folder with that name, you can keep your random also
if (copy($tmp_name, "$uploads_dir/$name")){
echo "successfully =>". $name;
}else{
echo "Not Uploaded Files";
}
1.Whole code Create a Index.php
<?php
if(isset($_POST['Submit'])){ //upload
$uploads_dir = 'image/';
foreach ($_FILES["multifileselect"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["multifileselect"]["tmp_name"][$key];
$name = basename($_FILES["multifileselect"]["name"][$key]);
if (copy($tmp_name, "$uploads_dir/$name")){
echo "successfully =>". $name;
}else{
echo "Not Uploaded Files";
}
}
}
}?>
<html>
<head></head>
<body>
<form method="post" action="" name="frmact" enctype="multipart/form-data">
Upload File : <input type="file" id="multifileselect" name="multifileselect[]" multiple="multiple" style="margin-left:50px;" />
<input type="submit" name="Submit" value="submit" style="margin-left:50px;" />
</form>
</body>
</html>
.
ReplyDelete