Learn to program PHP multiple file upload applications. Which is the art of uploading many files as an array in a single form request, and moving them to your server all at once. At the end of the lesson we link you to an Ajax and PHP file upload application with HTML5 progress bar included that you can take to experiment with sending files through Ajax. We also discuss your server limits regarding how many files can your specific server can upload simultaneously and the size the files can be. Each server can be set differently by the server administrator using the php.ini configuration file.
example.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<form action="my_parser.php" method="post" enctype="multipart/form-data">
<p><input type="file" name="file_array[]"></p>
<p><input type="file" name="file_array[]"></p>
<p><input type="file" name="file_array[]"></p>
<input type="submit" value="Upload all files">
</form>
</body>
</html>
my_parser.php
// http://www.youtube.com/watch?v=7fTsf80RJ5wif(isset($_FILES['file_array'])){
$name_array = $_FILES['file_array']['name'];
$tmp_name_array = $_FILES['file_array']['tmp_name'];
$type_array = $_FILES['file_array']['type'];
$size_array = $_FILES['file_array']['size'];
$error_array = $_FILES['file_array']['error'];
for($i = 0; $i < count($tmp_name_array); $i++){
if(move_uploaded_file($tmp_name_array[$i], "test_uploads/".$name_array[$i])){
echo $name_array[$i]." upload is complete<br>";
} else {
echo "move_uploaded_file function failed for ".$name_array[$i]."<br>";
}
}
}
0 comments:
Post a Comment