
July 12th, 2002, 10:30 PM
|
|
|
|
Join Date: Jan 2002
Location: Pekin, IL
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
FTP Upload
I've been pouring over the following code all day, but can't seem to get it work. I appreciate anyone that can point out any errors.
PHP Code:
$imageUpFile = $_FILES['file']['tmp_name'];
$imageType = $_FILES['file']['type'];
$imageName = $_FILES['file']['name'];
echo" $imageUpFile, $imageType, $imageName";
//Open the uploaded pic (temp file)
if ($thePic = fopen ($imageUpFile, "rb"))
{
//read temp file into var
$savePic = fread($thePic, filesize($imageUpFile));
//Open a new file in the correct directory using the name of the uploaded pic file
if ($fileHandle = fopen("ftp://username:apassword@somehost.com/htdocs/www/uploads/$imageName","w"))
{
//Put data into just opened file pointer
if (fwrite ($fileHandle, $savePic))
{
echo "file <b>$imageName</b> successfully written";
}
else
{
echo "file <b>$imageName</b> was NOT written";
}
}
fclose ($fileHandle);
fclose ($thePic);
}
else
{
// The file was not created. Inform the user.
echo "<b> The file: $imageUpFile could not be created!</b>";
}
|