...

View Full Version : php file uploader



cra992
06-06-2005, 02:57 AM
how do i make a php file uploader??

Brandoe85
06-06-2005, 03:24 AM
http://www.php.net/features.file-upload

anshul
06-06-2005, 07:37 AM
Some rough code:
<form action=<?php echo $PHP_SELF; ?> method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<input name="userfile[]" type="file" class="text"><br>
<input name="userfile[]" type="file" class="text"><br>
<input name="userfile[]" type="file" class="text"><br>
<input name="userfile[]" type="file" class="text"><br>
<input name="userfile[]" type="file" class="text"><br>
<br>
<input style="width:50%; font-weight:bold;" name="submit" type="submit" class="text" value="UPLOAD" align="center">
</form>

if ($_POST['submit']=="UPLOAD") {
for($i=0; $i<5; $i++) {
if($_FILES['userfile']['size'][$i]>"1048576")
echo "<pre>Can't upload a file; filesize > 1 mb or 1024 kb or 1048576 bytes.</pre>";
if ( ($_FILES['userfile']['size'][$i]<="1048576") && ($_FILES['userfile']['tmp_name'][$i]!="") ) {
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $_SERVER['DOCUMENT_ROOT']."/images/".$_FILES['userfile']['name'][$i])) {
echo "<pre>Upload successful.\n";
echo "File: ".$_FILES['userfile']['name'][$i]." (".$_FILES['userfile']['size'][$i].") bytes\n";
echo "Renamed: ".$_FILES['userfile']['name'][$i]."</pre>\n";
}
else
echo "<pre>Can't upload file due an error.</pre>";
}
if( ($_FILES['userfile']['tmp_name'][$i]=="") && ($_FILES['userfile']['size'][$i]=="0") )
echo "<pre>No file specified.</pre>";
}
}
http://www.mediasworks.com/ (http://www.mediasworks.com/webstory/cghost/home.htm)

cra992
06-06-2005, 12:07 PM
it works...the file gets uploaded
but under that this comes up:

Notice: Undefined offset: 1 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 4

Notice: Undefined offset: 1 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 1 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 1 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 1 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 2 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 4

Notice: Undefined offset: 2 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 2 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 2 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 2 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 3 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 4

Notice: Undefined offset: 3 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 3 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 3 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 3 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 4 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 4

Notice: Undefined offset: 4 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 4 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 6

Notice: Undefined offset: 4 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Notice: Undefined offset: 4 in C:\Program Files\Abyss Web Server\htdocs\upload2.php on line 15

Does anyone know how to fix this??

cra992
06-06-2005, 02:38 PM
found a script that works here (http://www.tizag.com/phpT/fileupload.php)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum