Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need MIME TYPE Help! PLEASE! 1

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
I need a form to accept Microsoft Word documents, Rich Text, or plain-text files within php-

My code looks like this:

if ("application/msword" == $uploadedfile_type) {
$extension = ".doc";
}
if ("application/rtf" == $uploadedfile_type) {
$extension = ".rtf";
}

else {
$extension = ".txt";
}


if ($uploadedfile_type == "text/plain"
or $uploadedfile_type =="application/rtf"
or $uploadedfile_type == "application/msword")
// HANDLE THE FILE
{
// Copy the file
if (is_uploaded_file($uploadedfile)) {
$filename = "./admin/attach/" . time() . $REMOTEHOST . $extension;
copy($uploadedfile, $filename);
echo ("File sucessfully saved as $filename");
}
else {echo ("No attachment file saved.");
}

I had it all working with word docs and .txt files until I tried to add Rich Text-

Any help would be appreciated!

-TIA
--Allen
 
First of all, I personally don't feel the MIME information that you get from the browser is reliable. You should try uploading a RTF and echo the
Code:
$uploadedfile_type
varible, to see what mime type is actually being set.

The
Code:
$uploadedfile_name
variable will give you the original file name as well

Nice tutorial I've used:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top