Code: Select all
<form name="e;myform"e; method="e;post"e; action="e;http://home.ripway.com/2005-6/328190/uploadtest.php"e; enctype="e;multipart/form-data"e;>Moderator: General Moderators
Code: Select all
<form name="e;myform"e; method="e;post"e; action="e;http://home.ripway.com/2005-6/328190/uploadtest.php"e; enctype="e;multipart/form-data"e;>Code: Select all
phpinfo();Code: Select all
file_uploads On OnCode: Select all
<html><body>
<?php
ini_set("file_uploads","1");
echo '<HR><PRE>'; print_r($_FILES); echo '</PRE>';
?>Code: Select all
<?php
// Fill this in. Must end with a slash / and it needs to be created and you need write permission 0777
$uploads_directory = $_SERVER['DOCUMENT_ROOT'] . '/images/';
//Find url: self
$self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
// Make form
echo <<<END
<form action="$self" enctype="multipart/form-data" method="post">
<input name="file[]" type="file" id="file[]"><br>
<input name="file[]" type="file" id="file[]"><br>
<input name="file[]" type="file" id="file[]"><br>
<input type="submit" name="Submit" value="Submit"></form><br>
END;
//Save uploaded files
$i = 0;
while(isset($_FILES['file']['name'][$i])){
if(!empty($_FILES['file']['name'][$i])){
if($_FILES['file']['error'][$i]==0){
if(!file_exists($uploads_directory . $_FILES['file']['name'][$i])){
if(is_uploaded_file($_FILES['file']['tmp_name'][$i])){
if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $uploads_directory . $_FILES['file']['name'][$i])) {
print("Success saving the file '{$_FILES['file']['name'][$i]}' (file
number '$i' in the array) in the directory '$uploads_directory' <br>");
}else{
print("Failure saving the file '{$_FILES['file']['name'][$i]}' (file
number '$i' in the array) in the directory '$uploads_directory' <br>");
}
}
}else{
print("A file named '{$_FILES['file']['name'][$i]}' (file number '$i' in
the array) already exists in the directory '$uploads_directory'. Please rename
your file and try again <br>");
}
}
}
$i++;
}
?>