Jump to content

Recommended Posts

Is there any way to check a file to see if it is fully written before trying to use/manipulate it? I have a Flex application that calls a PHP script which executes an ImageMagick function to create a thumbnail of an image. The images are uploaded at any time so there has been a few occasions where the image is uploading (incomplete) when ImageMagick tries to make the thumbnail and of course it fails.

 

So I'm looking for a way through PHP to check if the file is fully written before trying to do anything with it. If it's not fully written, I'll ignore it and move on but I need to add this safety check in to prevent any errors.

 

Any ideas??? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/100611-check-completeincomplete-files/
Share on other sites

What's a fully written file versus an incomplete file?

 

A "fully written file" or whatever the freak terminology is for it is when a file has all of its bytes and information written to it as in "3,278 of 3,278 bytes" whereas an "incomplete file" or whatever the freak terminology is may have not received all of the bytes yet as in "2,192 of 3,278 bytes". It's a lot like when you're downloading or uploading a file, you know how it's sometimes not instantly complete? Well trying to use incomplete files usually doesn't work too well in any situation whether it's on your PC or a server and that's what I'm trying to avoid - it not working well because it's not a complete file.

The best way to do this is to use a database... Once your PHP script has uploaded the file completely, add an entry to a db with the file name.

 

The flex app grabs the db rows, and converts them to thumbnails. Once the conversion is complete, delete the row.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.