Hi!
I have a small form which posts a filename for upload by ftp to my server,
<Form method="POST" enctype="multipart/form-data" action="FTPUpload.php">
<INPUT TYPE=file name=browse style="display:none;">
<input type=button onclick="browse.click();file.value=browse.value;browse.disabled=true;" value="Image To Upload">
<input type=text name=file>
<input type="Submit" name="submit" value="Upload Image">
</Form>
And a php script to do the actual upload,
<?
echo "<html><head><title>FTP Upload</title></head><body>";
$sourcefile = $_POST['file'];
$destfile = '/gallery/' . basename($sourcefile);
$conn = ftp_connect("MyServer");
if (!$conn)
{
echo "FTP Connection Failed<br><br>";
}
else
{
echo "FTP Connection Successfull<br><br>";
$login_result = ftp_login($conn, "MyUsername", "MyPassword");
if (!login_result)
{
echo "FTP Login Failure<br><r>";
}
else
{
echo "FTP Login successfull<br><br>";
$upload = ftp_put($conn, $destfile, $sourcefile, FTP_BINARY);
if (!upload)
{
echo "FTP Upload Has Failed<br><br>";
}
else
{
echo "FTP Upload Successfull<br><br>"
}
}
}
ftp_close($conn);
echo "</body></html>";
?>
The main problem I have is the path for sourcefile is always in the format "C:\path\Image.jpeg", because of this I have found that the basename function does not work, and just returns the entire path and filename.
Any Suggestions would be much appreciated.