[Phpwm] file upload complete?
Dave Holmes
dave at neteffekt.co.uk
Wed Jul 2 15:48:52 BST 2008
The following seems to work for us in one of our FTP import routines we
check the file size with a sleep in the middle
$this->write_debug(date('d/m/Y
H:i:s') . " - Import file found, checking for completed upload - " .
$upload_file);
$first_file_size =
filesize($upload_file);
$this->write_debug("Initial filesize
- " . $first_file_size);
sleep(UPLOAD_DETECTION_TIME);
clearstatcache();
$compare_file_size =
filesize($upload_file);
$this->write_debug(date('d/m/Y
H:i:s') . " - compare filesize - " . $compare_file_size);
# Only continue if the filesizes
have not changed
if ($first_file_size ==
$compare_file_size) {
# Should be safe to import, we
need to work out what type of file this is
$this->write_debug("Filesize
unchanged the file will be processed");
Alex Mace wrote:
> I haven't personally tried using feof in that situation, so I couldn't
> tell you for sure, but I don't think that it would work.
>
> Perhaps checking the modification time to see if it's changed in the
> last (say) 5 minutes and ignoring it if it has until that time has
> passed would be a better solution? Or use an FTP server that you can
> script to move completed uploads to another location?
>
> Alex
>
> On 2 Jul 2008, at 15:40, alan dunn wrote:
>
>> We have zip files being uploaded to an FTP folder from various
>> laptops. We then plan to open those files using a cron job. My
>> concern is that we shouldn't try to open and process a file before
>> upload is complete.
>>
>> Is it OK to just use feof = true going to do this or do we need to
>> be more thorough?
>>
>> Are there methods of monitoring a file to see when upload is complete
>> and then switching on the next stage of the process?
>>
>> thanks, alan dunn
>> --
>>
>> DISCLAIMER:
>>
>> This document originates from within Dunns Imaging Group Limited.
>> This message, together with any associated files, is intended only
>> for the use of the individual or entity to which it is addressed and
>> may contain information that is confidential, subject to copyright or
>> constitutes a trade secret. If you are not the intended recipient of
>> this communication you are hereby notified that any dissemination,
>> copying or distribution of this message, or of any files associated
>> with this message, is strictly prohibited.
>> If you have received this message in error, please notify us at once.
>>
>> Dunns Imaging Group Ltd.
>> Registered Office: Chester Road Cradley Heath West Midlands B64 6AA.
>> Tel: 01384 564770
>> Registered in England 598527.
>>
>>
>> _______________________________________________
>> Phpwm mailing list
>> Phpwm at mailman.lug.org.uk
>> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/phpwm/attachments/20080702/19d8f541/attachment.html
More information about the Phpwm
mailing list