ftp image uploading problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ghostz00
Forum Newbie
Posts: 2
Joined: Sun Jun 12, 2005 2:49 pm

ftp image uploading problem

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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);
ghostz00
Forum Newbie
Posts: 2
Joined: Sun Jun 12, 2005 2:49 pm

Post by ghostz00 »

Thanks a lot d11wtq, that worked perfectly. I've been working on that for the past hour.
Post Reply