note 3772 deleted from features.file-upload by jimw
| From: | jimw@php.net | Date: | Wed, 02 Jan 2002 00:22:46 +0000 |
| Subject: | note 3772 deleted from features.file-upload by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24048@lists.php.net to get a copy of this message | ||
I've found this code useful to use where there seem to be problems with the file permissions.
Takes the temp file and uploads it via FTP to your web area.<br>
Typical usage would be <b>uploadFile( $uploadFile , "ftp.server.com",
"userName", "password", "reviewThisFile_jpg.exe");<br>
I found that if i used an exe extension it would transfer in binary mode OK so the images
wouldn't get munched.
<br>
<pre>
function uploadFile( $srcFileName , $ftpServerAddress, $ftpUser, $ftpPassword, $ftpFileName ){
// open source file for reading
$sfile = fopen($srcFileName,r);
if( $sfile ){
echo("File open succeeded<br>");
echo("<<DEBUG>> ftp://" . $ftpUser .
":" . $ftpPassword . "@" . $fptServerAddress . $ftpFileName );
$dfile = fopen("ftp://" . $ftpUser . ":" .
$ftpPassword . "@" . $ftpServerAddress . $ftpFileName ,w);
if( $dfile ){
echo("File open to FTP succeeded<br>");
fwrite( $dfile, fread($sfile, filesize($srcFileName)));
fclose( $dfile );
}else{
echo("File open to FTP failed miserably<br>");
}
fclose( $sfile );
}else{
echo("File open failed miserably<br>");
}
}
</pre>