Page 1 of 1

Uploaded PDF Files Becoming Corrupt

Posted: Thu Jun 10, 2010 7:04 am
by rklockner
Users of our software can upload files to the server (linked to deals they are working on). The code used is below.

Code: Select all

$uploaddir = "uploaded_files/";

$f = $_FILES["doc"];

$file_id = uniqid();

$n = $uploaddir . $file_id . "." . get_ext($f["name"]);

copy($f["tmp_name"], $n);
It no seems to be occurring more and more that after these files are uploaded they are not able to be opened, and a "File Corrupt" error. Any thoughts?

Re: Uploaded PDF Files Becoming Corrupt

Posted: Thu Jun 10, 2010 9:28 pm
by yacahuma
open the pdf with a text editor like notepad++. If you have spaces at the beginning, most likely your have spaces in your libraries after the end php terminator (?>)