note 27387 added to function.fopen
| From: | marcusleblanc at rogers dot com | Date: | Wed, 04 Dec 2002 04:31:21 +0000 |
| Subject: | note 27387 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40324@lists.php.net to get a copy of this message | ||
I am getting the following error when only uploading images via ftp. Text files work fine. I am
running this code on Linux running apache and PHP 4. Any help would be appreciated.
Warning: fopen(ftp://user:password@ftpserver directory) [function.fopen]: failed to create stream:
Inappropriate ioctl for device in /home/user/public_html/development/Administration/imageupload.php
on line 17
Warning: fclose(): supplied argument is not a valid stream resource in
/home/user/public_html/development/Administration/imageupload.php on line 40
Below is the code that I am using to upload.
<?$imageUpFile = $_FILES['userfile']['tmp_name'];
$imageType = $_FILES['userfile']['type'];
$imageName = $_FILES['userfile']['name'];
//if(isset($submit)){
//Open the uploaded pic (temp file)
if ($thePic = fopen ($imageUpFile, "rb"))
{
//read temp file into var
echo filesize($imageUpFile);
$savePic = fread($thePic, filesize($imageUpFile));
//Open a new file in the correct directory using the name of the uploaded pic file
$ftpconnect = "ftp server info";
if ($fileHandle = fopen($ftpconnect, "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>";
}
//}
?>
--
http://www.php.net/manual/en/function.fopen.php
http://master.php.net/manage/user-notes.php?action=edit+27387
http://master.php.net/manage/user-notes.php?action=delete+27387
http://master.php.net/manage/user-notes.php?action=reject+27387