Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a rather simple app in .net which uploads images in fixed intervals in an ftp server.

The file name is specific.

I need to have a web page that refreshes but i want this to happen only when the upload finishes.

How i find a way to determine that the upload has finished? And if the solution has to do with renaming and deleting temp files, should i do this from the windows app or server side?

Thanks

update: What if i could find a way to check if a filename is a valid jpg? I mean if the transfer is not over this check should return false..ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

JPEG files use a marker 0xFF 0xD9 to indicate end of image. If that marker is not present in the file, either the upload failed or did not yet finish. Scanning the file for this marker should be sufficient to check for incomplete upload.

This won't however detect any corruption within the image data itself. A way to ensure the integrity of the data would be to generate a CRC checksum before the upload in the desktop app, pass the checksum to the ftp (in the image filename or a separate file) and then compare the checksum of the uploaded file in the server-side code.

This assumes the web app would attempt to autonomously update in fixed intervals. Alternatively you could use a webservice or a dummy page to trigger the update from the desktop app.

share|improve this answer
    
Thanks! Any php code for the marker check? –  e4rthdog Apr 21 '12 at 11:13
    
scrwtp pointed to the correct direction. Found the code to check the eof here: [enter link description here][1] [1]: stackoverflow.com/questions/1459882/… –  e4rthdog Apr 21 '12 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.