Post to upload.php using a form with a file field called imageFiles[].
e.g.
<form enctype="multipart/form-data" action="upload.php?upload" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="imageFiles[]" type="file">
<input type="submit" value="Send File">
</form>
Here is the upload script i use.
If there is a URL variable called upload the script will be executed
upload.php
[PHP CODE]
if(isset($REQUEST["upload"]))
{
$ftp_server = "xxx.xxx.xxx.xxx";
$username = "ftpusername";
$password = "ftppassword";
$public_dir = "public_html/graphics/"; // the webroot or the place where you want to move the file.
$source = $FILES['imageFiles']['tmp_name'][0];
//this is where you chode the destination filename
$destination = ('test_tn.jpg');
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $username, $password);
// check connection
if ((!$conn_id) || (!$login_result))
{
echo("FTP connection has failed!");
echo("Attempted to connect to $ftp_server for user $ftp_user_name<br>");
die;
}
else
{
echo("Connected to $ftp_server, for user $username<br>");
}
// upload image
$upload = ftp_put($conn_id, $public_dir."/".$destination, $source, FTP_BINARY);
// check upload status
if (!$upload)
{
echo "FTP upload to $ftp_server has failed!";
}
else
{
echo "Uploaded $source to $ftp_server as $destination<br>";
}
// close the FTP stream
ftp_quit($conn_id);
}
[/PHP CODE]
you can find out various info on the uploaded file using the following:
$_FILES['userfile']['name']
The original name of the file on the client machine.
$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An example would be "image/gif".
$_FILES['userfile']['size']
The size, in bytes, of the uploaded file.
$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES['userfile']['error']
The error code associated with this file upload. ['error'] was added in PHP 4.2.0
You also need to ensure your hosting allows file uploads, in my experience there are quite a few that don't
I hope this helps you.