Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php file uploader

    how do i make a php file uploader??

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Some rough code:
    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>
    Code:
    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/

  • #4
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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??

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    found a script that works here


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •