Date: 07/13/01
- Next message: Jordan: "[PHP-DB] Interbase/PHP/Apache implimentation"
- Previous message: comp.mail.sendmail: "Re: [PHP-DB] upload problem ..."
- Next in thread: comp.mail.sendmail: "[PHP-DB] Re: upload problem ..."
- Reply: comp.mail.sendmail: "[PHP-DB] Re: upload problem ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>]
Sent: Friday, July 13, 2001 10:28 AM
To: php-db <email protected>
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.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Jordan: "[PHP-DB] Interbase/PHP/Apache implimentation"
- Previous message: comp.mail.sendmail: "Re: [PHP-DB] upload problem ..."
- Next in thread: comp.mail.sendmail: "[PHP-DB] Re: upload problem ..."
- Reply: comp.mail.sendmail: "[PHP-DB] Re: upload problem ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

