I have created a simple form to upload a picture from the browser to a location on my webserver. I keep getting an error message that I have not found the answer to anywhere on the web:
Warning: ftp_put(): Type set to I in /home/enduroauto/www/www/upload_picture_test.php on line 51
The following is the code for the form (upload_picture_form.htm):
<html>
<head>
<title></title>
</head>
<body>
<form action="upload_picture_test.php" method="post" enctype="multipart/form-data">
Click the Browse button to find the file you wish to upload
<input type="file" name="imagefile">
<INPUT TYPE="submit" name="upload" value="upload">
</form>
</form>
</body>
</html>
Here is the code for the handler (upload_picture_test.php)
<html>
<head>
<title>Image Uploader</title>
<body
<?php
//logon values
$ftp_user_name='username';
$ftp_user_pass='password';
$ftp_server='ftp.webserver.com';
$ftp_dir='/Magazine/';
//$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.
$web_dir='/Magazine/';
$web_location=$web_dir.$imagefile_name;
//build a fully qualified (FTP) path name where the file will reside
$destination_file=$ftp_dir.$imagefile_name;
//ftp_pasv($conn_id, 0);
// 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
ftp_close($conn_id);
//verify file was written
if (file_exists($web_location))
{
echo "file was uploaded as $web_location";
}
else
{
echo "Could not create $web_location";
}
//end if
?>
</form>
</body>
</html>