Rank: Member
Groups: Member
Joined: 1/6/2010(UTC) Posts: 15
|
Is there a method to check whether the original file was uploaded? Users on my site have an option to toggle sending originals or just thumbnails. Sure, I can set the value as an additional form element before upload, but I'd rather not check that. I can moreover check the raw $_FILES or $_POST requests sent to the server. However, I'm looking for a cleaner way. Is there one presently? I was calling getFileName() and getContentLength() on $file->getSourceFile(), and well, when the original is sent these methods return their respective value; however, when the original is not uploaded, these values cause an error in the PHP script. It would be smart if these values simply returned "false" instead of returning an error that kills your script. That way I could just do something like this: Code:
$is_original_uploaded = ($o_file->getContentLength()) ? $o_file->getContentLength() : 0;
// then just check if $is_original_uploaded is greater than 0; if it is, then we know the original has been uploaded.
Do you guys have a recommendation?
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 6/16/2009(UTC) Posts: 134
Was thanked: 8 time(s) in 8 post(s)
|
You can do something like that: Code:$is_original_uploaded = false;
try {
$is_original_uploaded = $file->getSourceFile()->getContentLength() > 0; // Exception will be thrown if source file does not exist.
} catch ($e) {
$is_original_uploaded = false;
}
Edited by user Wednesday, June 16, 2010 7:34:50 PM(UTC)
| Reason: Not specified |
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.