Re: upload problem ...

From: Date: Fri, 13 Jul 2001 17:48:28 +0000
Subject: Re: upload problem ...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10393@lists.php.net to get a copy of this message
File 1 (whateverform.php): ------------------------------------ <FORM ENCTYPE="multipart/form-data" ACTION="fileupload-destination.php" METHOD=POST> <INPUT TYPE='File' NAME='alfredoUpload'> </FORM> ------------------------------------ File 2 (fileupload-destination.php): ------------------------------------ if (is_uploaded_file($alfredoUpload)) { // Uncomment the following line ONLY if you're on Red Hat 7.0 // $Fix_RH7_Upload = fix_php_rh7_upload_bug($alfredoUpload); // Move to directory $filename = basename ($alfredoUpload_name); move_uploaded_file($alfredoUpload, "/home/mydirectory/uploadfolder/" . $filename); } // ################################# // Fix PHP Upload Bug on Red Hat 7.0 // ################################# function fix_php_rh7_upload_bug($tmp) { $infile=fopen($tmp,"r"); // Open the file for the copy $outfile=fopen("$tmp.new","w"); // create a new temp file $header=fgets($infile,255); //get the 1st line (netscape sometimes doesn't add a Content-type line) //if its more than just a \r\n sequence then if (strlen($header)>2) $header=fgets($infile,255); //get next line also while(!feof($infile)) { // Loop through the remaining file $temp=fread($infile,128); fwrite($outfile,$temp,strlen($temp)); //copying contents to new temp file } fclose($outfile); fclose($infile); copy("$tmp.new","$tmp"); //replace the original with our new bug fixed file unlink("$tmp.new"); //and delete the new file return filesize($tmp); //return a true file size } ------------------------------------ You can post the upload to the same file if you want (so File 1 AND File 2 are whateverform.php). I just split them up for this example. I don't take credit for the fix_php_rh7_upload_bug function. That was posted by someone else on the PHP documentation. - Jonathan -----Original Message----- From: comp.mail.sendmail [mailto:alfredo@sankofasystems.com] Sent: Friday, July 13, 2001 10:28 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] upload problem ... Could anyone send me the actual code for doing the files upload to a linux box with php. I know the form for the upload but not the php file that does the upload . Thanks everyone.

« previous php.db (#10393) next »