Page 1 of 1

ftp image uploading problem

Posted: Sun Jun 12, 2005 2:59 pm
by ghostz00
I am having a problem uploading image files using php. im using the file type input.

Here's the code

Code: Select all

$destination_file="/pics2/thumb".$id.".jpg";
	 $destination_file2="/pics2/large".$id.".jpg";
				
	// upload the file
	$upload = ftp_put($conn_id, $destination_file, $_FILES['thumb'], FTP_BINARY);
	$upload2= ftp_put($conn_id, $destination_file2, $_FILES['largepic'], FTP_BINARY);
				
	// check upload status
	if (!$upload) {
        echo "FTP upload has failed!";
	 } else {
	echo "Uploaded $source_file to $ftp_server as $destination_file";
	}
				
	// close the FTP stream
	ftp_close($conn_id);
It uploads the picture but it has 0 bytes.

Posted: Sun Jun 12, 2005 3:38 pm
by Chris Corbyn
The $_FILES[] array is multidimensional. The path to the uploaded file is actually $_FILES['form_field_name']['tmp_name']

Code: Select all

$destination_file="/pics2/thumb".$id.".jpg";
     $destination_file2="/pics2/large".$id.".jpg";
                
    // upload the file
    $upload = ftp_put($conn_id, $destination_file, $_FILES['thumb']['tmp_name'], FTP_BINARY);
    $upload2= ftp_put($conn_id, $destination_file2, $_FILES['largepic']['tmp_name'], FTP_BINARY);
                
    // check upload status
    if (!$upload) {
        echo "FTP upload has failed!";
     } else {
    echo "Uploaded $source_file to $ftp_server as $destination_file";
    }
                
    // close the FTP stream
    ftp_close($conn_id);

Posted: Sun Jun 12, 2005 3:59 pm
by ghostz00
Thanks a lot d11wtq, that worked perfectly. I've been working on that for the past hour.