Page 2 of 2
Posted: Thu Jul 07, 2005 4:04 pm
by hawleyjr
If your form looks like:
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;>
Then it should work...?
Posted: Thu Jul 07, 2005 4:06 pm
by IceMetalPunk
Well that is what it looks like, and it doesn't work.... Can anyone else help?
-IMP

Posted: Thu Jul 07, 2005 4:09 pm
by hawleyjr
Is File Upload enabled on your machine?
Look for:
Posted: Thu Jul 07, 2005 4:15 pm
by Burrito
hawley is right on target.
how big is the file you're trying to upload? If it's over 2MB then you've exceeded what the default is set for in php.ini. You need to change the max upload size and the max post size...
Posted: Thu Jul 07, 2005 4:18 pm
by IceMetalPunk
That's the problem! file_uploads is off.... but this is on another server.... is it possible to change the settings for this through PHP?
-IMP

Posted: Thu Jul 07, 2005 4:22 pm
by Burrito
ini_set()
EDIT: although I'm not sure you can do it with that directive
Posted: Thu Jul 07, 2005 4:25 pm
by IceMetalPunk
Hmmm... now my code looks like this:
Code: Select all
<html><body>
<?php
ini_set("file_uploads","1");
echo '<HR><PRE>'; print_r($_FILES); echo '</PRE>';
?>
And it STILL returns a blank array....Does this mean that my host (Ripway) doesn't allow uploads from user PHP scripts?
-IMP

Posted: Thu Jul 07, 2005 4:27 pm
by Burrito
IceMetalPunk wrote:Does this mean that my host (Ripway) doesn't allow uploads from user PHP scripts?
I suppose it could?? contact them and find out

Posted: Thu Jul 07, 2005 4:57 pm
by bokehman
Hello friend! If you are still having trouble you may find the answers you need in the script I am posting. It is a complete and working but compact script which shows everything needed for file upload and save operations.
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++;
}
?>