我如何检查文件是否完全上传... ??? [英] how can i check if a file is completely uploaded...???

查看:91
本文介绍了我如何检查文件是否完全上传... ???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我为客户创建了一个应用程序,客户可以将
..csv文件上传到指定的ftp -目录。在服务器上,一个由cronjob触发的php脚本,
读取所有数据,将其导入mySQL数据库

并删除.csv文件后导入。


到目前为止,非常好。


但在某些情况下,当文件不完整时,cronjobs开始运行

已上传。所以数据的一部分被截断了。 :-(


是否有任何方法在PHP中检查文件是否完全通过ftp上传

或不?我没有找到任何关于这在php.net上会很棒,如果

有人可以帮我解决这个问题。


提前多多感谢,

dino

dear all,

i''ve created an application for a customer where the customer can upload
..csv-files into a specified ftp-directory. on the server, a php-script,
triggered by a cronjob, reads all the data, imports it into a mySQL database
and deletes the .csv-file after the import.

so far, so good.

but in some cases the cronjobs starts running when the file is not completely
uploaded. so a part of the data is truncated. :-(

is there any method in php to check if a file is completely uploaded via ftp
or not? i didn''t find anything about this on php.net and it would be great if
someone could help me with this problem.

thanks a lot in advance,
dino

推荐答案

嗯也许你可以查看文件大小?使用php函数....


我也有过与你相同的经历......我所做的是手动完成

cronjonb两次..所以它会确保文件完成ftp

首先..


可能是我们需要更多经验的php用户来帮助解决这个问题..

提前预订

hmm maybe u can check the file size? using php function....

I also had experience same with you ... what I do is manually do the
cronjonb twice.. so it will make sure the file will finished ftp
first..

may be we need more experience php user to help on this matter..
thannks in advance


2005年3月19日04:30:36 -0800,badz< ba **** @ gmail.com>写道:
On 19 Mar 2005 04:30:36 -0800, "badz" <ba****@gmail.com> wrote:
嗯也许你可以查看文件大小?使用php函数....

我也有过与你相同的经历...我是什么做的是手动做两次cronjonb ..所以它会确保文件完成ftp
首先..

可能是我们需要更多经验的php用户来帮助这个事情..
提前知道
hmm maybe u can check the file size? using php function....

I also had experience same with you ... what I do is manually do the
cronjonb twice.. so it will make sure the file will finished ftp
first..

may be we need more experience php user to help on this matter..
thannks in advance




你好,


感谢你的投入,问题是,那个文件大小改变

关于.csv文件中行数的不同。


i想到了2种可能的解决方案,但它们有点便宜 br />
变通办法而不是一个干净的解决方案:


第一个想法:我要求客户在.csv的底部添加额外的一行

,例如" ### endoffile ###" ;.在php cronjob开始之前

工作它检查.csv是否存在此

end-of-document-flag。


第二个想法:我要求客户上传另一个带有

特殊文件名的小文件,例如" startjob.txt" _AFTER_上传主

文件。如果php conjob没有找到这个文件,它会立即退出。

(导入后的课程 - 两者都会自动删除)


虽然这可能有用,我不认为这是

所有的完美解决方案。也许有人在这里有一个原生的方法检查文件是否已完成上传。


最好的问候,

dino



hello,

thanks for your input, the problem is, that the filesizes changes
depandant on the number of line in the .csv file.

i thought about 2 possible solutions, but they are kind of "cheap
workarounds" instead of a clean solutions:

1st idea: i ask the customer to add an additional line at the bottom
of the .csv, e.g. "###endoffile###". before the php cronjob starts
working it checks the .csv for the existance of this
"end-of-document-flag".

2nd idea: i ask the customer to upload another small files whith a
special filename e.g. "startjob.txt" _AFTER_ the uploading of the main
file. if the php conjob does not find this file, it exits immediately.
(after the import -of course- both will will be deleted automatically)

although this may work, i don''t think it''s the perfect solution at
all. maybe someone here has a "native" method to check if a file is
completey uploaded.

best regards,
dino


Dino< no **** @ yahoo.com>写道:
Dino <no****@yahoo.com> wrote:
虽然这可行,但我认为这不是所有的完美解决方案。也许有人在这里有一个原生的检查文件是否完整上传的方法。
although this may work, i don''t think it''s the perfect solution at
all. maybe someone here has a "native" method to check if a file is
completey uploaded.




您正在使用flock获得独家锁定,不是吗?



You are using flock to get an exclusive lock, aren''t you?


这篇关于我如何检查文件是否完全上传... ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆