Page 1 of 1

PHP Upload Directory Help

Posted: Tue Aug 26, 2003 5:50 am
by Method
I have currently been working with a php upload script that works, but uploads to the same directory as the file... I have been searching for a way to upload to a specific directory ie. /uploads/ but can't seem to get it working.. here is my code that i have so far... (mind you this is only the php file):

Code: Select all

<? 
if ($HTTP_POST_VARS['submit'])  
{ 
	$source = $_FILES['file']['tmp_name'];
	$sourceend = $_FILES['file']['name'];
	$path = "uploads/";

    if (!is_uploaded_file($source))  
    { 
    $error = "You did not upload a file!"; 
    @unlink($source); 
    print "You did not enter a file to upload.";
    } 
    else  
    { 
    $maxfilesize=300000; 
        if ($source > $maxfilesize) 
        { 
            $error = "File is too large."; 
            @unlink($source); 
        } 
        else  
        { 
        	 @chmod($path, 01777);
             @copy($source, $path . $sourceend);
             @unlink($source);
    	     @chmod($path, 01744);
        } 
        

         print "File has been successfully uploaded!<br><a href="index.html">Click here to Return</a>"; 
             exit;   
 
            }  
      } 

?>
Any help would be GREATLY appreciated!

Posted: Tue Aug 26, 2003 10:46 am
by xisle
Is the $path set to your destination directory? It looks ok otherwise.

Posted: Tue Aug 26, 2003 6:59 pm
by Method
yes it is set to that directory...

Posted: Tue Aug 26, 2003 10:28 pm
by Method
blah... i found the error...

i just needed to set the $path = "uploads/"; to $path = "uploads//";

it works fine now...