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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading files to Phorum

Status
Not open for further replies.

solstice43

Technical User
Jul 26, 2001
3
US
I am running Phorum 3.3.2a on a Win2000 Server, running Apache 1.3.20 and PHP4.0.6 as a module. I'm using IE5.5 SP2, and Netscape 6 as browsers, and having the same problem on each.

The problem is with attaching files to my messages. The upload appears to work correctly, but when I click on the link to download e.g. a Word document I am getting a screen full of garbage characters in the browser.

It appears that a series of blank characters is being inserted at the beginning of the files, so that the file is corrupted. I have tried opening the files directly from the file upload directory and they are OK, so it appears that the corruption is happening when the files are being served.

Does anyone have any ideas?


 
How do you link the files?

If you link them directly, the redskin only sets the content-type if he knows about it by either file extension or the first bytes of the file.

If he knows not about it, he sends it as his default type, whats per default text/plain.

If this is on, the browser needs to know how to handle the file correctly.

Try to save the file via context menu-save-as. If you can open that saved file correctly, you need to tell your browser the corretc content-type for that file (i. e.: application/msword for Word .doc files).

For a comprehensive listing of content-types see
HTH, Sascha cu, Sascha
 
Sascha,

The link is set to to point to a URL similar to the following:

(download.php/1,1,1/test.doc)

The download.php script then extracts the correct pathname to the file which sits in a directory outside of the web root. The files in the directory are at this stage not corrupted.

The script assigns a mime type by examining the file extension and checking against an array of mime types, then passes this mimetype in a header, along with a Content-Disposition header:


header("Content-Type: $mime");
header("Content-Disposition:attachment; filename=\"$file\"");

Then fopen with parameter "rb" is used to open the file, and fpassthru used to dump it out.

I've tested the point returned from fopen and it's definitely pointing to the first valid character of the file. However once the file appears in the browser, it appears that newline or linefeeds have been inserted, but I don't know where they could be coming from?


 
In the end it turned out to be the fact that when the file was being copied (using move_uploaded_file) to its final destination directory from the temporary upload directory, a chmod (0666) command was being applied to the file permissions.

When I removed this line, the file opened without any problems. Apparently the script includes this because Unix needs it, but it seems to cause a corruption of the file in Windows2000/NT.

Thanks for all help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top