note 27387 rejected from function.fopen by betz

From: Date: Wed, 04 Dec 2002 11:07:38 +0000
Subject: note 27387 rejected from function.fopen by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-40335@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>"; } //} ?>

« previous php.notes (#40335) next »