Uploaded PDF Files Becoming Corrupt

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rklockner
Forum Newbie
Posts: 22
Joined: Tue Feb 09, 2010 9:56 am

Uploaded PDF Files Becoming Corrupt

Post 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?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Uploaded PDF Files Becoming Corrupt

Post 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 (?>)
Post Reply