Jump to content

Files Becoming Corrupt


rklockner

Recommended Posts

I have a section where users can upload documents into our software.  The code itself is a couple years old and could perhaps use some updating, but it seems some of the files (at this time it only seems to be *.pdf) that have been uploaded are not able to be opened and the error "the file is damaged and could not be repaired" is being displayed as an "Adobe Reader" error in Internet Explorer 8.

 

The largest concern is that it is an irreversible error and many of the documents users have uploaded are now corrupt.  I can't seem to find any relevant information from Google (or Adobe) that does anything towards resolving the problem.

 

Note: This does not happen on every .pdf, and I am not sure if there is a common bond between the failing documents (trying to find this now).

Link to comment
https://forums.phpfreaks.com/topic/224116-files-becoming-corrupt/
Share on other sites

It appears that the user is closing the page early before the entire document is uploaded (but I'm still researching).

 

The upload code is:

$uploaddir = "docs/";

$f = $_FILES["doc"];
$file_id = uniqid();

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

copy($f["tmp_name"], $n);

 

FYI: get_ext() is a function to get the files extension (I'm sure you could have figured that out).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.