php upload not working

Discussion in 'PHP' started by asgsoft, May 6, 2010.

  1. #1
    I've been trying to get this to work and upload the file but it's not working!!

    	$target_path = "/upload_logo";
    	if(move_uploaded_file($_FILES['company_logo']['tmp_name'], $target_path)) {
    	echo "done";
    	}
    
    PHP:
    HELPPP!!!
     
    asgsoft, May 6, 2010 IP
  2. peoplesmind

    peoplesmind Active Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Put this line before your code, and see what it tells you:

    if ($_FILES["company_logo"]["error"] > 0) {
    	echo "Return Code: " . $_FILES["company_logo"]["error"] . "<br />";
    	switch ($_FILES['company_logo']['error']){
    		case 1:
    			echo 'The File is too Big.<br />PHP Installation Max File Size Error<br />';
    		case 2:
    			echo 'The File is too Big.<br />Form Specified Max File Size Error<br />';
    		case 3:
    			echo 'Only Part of the File was Uploaded.<br />';
    		case 4:
    			echo 'No File was Uploaded.<br />';
    		case 6:
    			echo "Missing a Temporary Folder.<br />";
    		case 7:
    			echo "Failed to Write File to Disk.<br />";
    		case 8:
    			echo "File Upload Stopped By Wrong Extension.<br />";
    	}
    }
    PHP:
     
    peoplesmind, May 6, 2010 IP
  3. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #3
    nothing comes up at all!
     
    asgsoft, May 6, 2010 IP
  4. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #4
    
    
    $target_path = "upload_logo/";
    
    $target_path = $target_path . basename( $_FILES['company_logo']['name']); 
    
    if(move_uploaded_file($_FILES['company_logo']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['company_logo']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    
    PHP:
     
    MyVodaFone, May 6, 2010 IP
  5. VarriaStudios

    VarriaStudios Member

    Messages:
    246
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #5
    enable permissions to folder
     
    VarriaStudios, May 6, 2010 IP
  6. Richskrenta

    Richskrenta Active Member

    Messages:
    170
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #6
    i think this code is right , you can try it . if you still got problem don't worry just reply this thread again , i will help you :)
     
    Richskrenta, May 6, 2010 IP