June 6th, 2003, 15:57
Compliments to a buddy of mine.... who gave this to me awhile ago...

echo '<form action="image_upload.php" method="post" enctype="multipart/form-data">';
echo 'Click the Browse button to find the file you wish to upload';
echo '<input type="file" name="imagefile">';
echo '<INPUT TYPE="submit" name="upload" value="upload">';
echo '</form>';
/************************************************** ************************************
************************************************** *************************************
************************************************** *************************************
*** <input type="file" name="imagefile"> ***
*** with the above tag declared in the calling form ***
*** the variable name is $imagefile and the available properties are ***
*** $imagefile :name of the file as stored on the temporary server directory ***
*** $imagefile_name :filename.extension of the file as on the users machine ***
*** $imagefile_size :size in bytes of the file ***
*** $imagefile_type :the type of file image/gif image/jpg text/html etc.... ***
*** ***
************************************************** *************************************
************************************************** *************************************
//change these values to suit your site
//$web_location is needed for the file_exists function, the directories used by FTP
//are not visible to it will will always return not found.

//build a fully qualified (FTP) path name where the file will reside

// connect, login, and transfer the file
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$upload = ftp_put($conn_id, $destination_file, $imagefile, FTP_BINARY);

//use ftp_site to change mode of the file
//this will allow it be visible by the world,
$ch=ftp_site($conn_id,"chmod 777 ".$destination_file);
// close the FTP stream

//verify file was written
if (file_exists($web_location))
echo "file was uploaded as $web_location";
echo "Could not create $web_location";
//end if