zip 文件保存不完整,教义::createquery->update()
我收到一个 zip 文件,需要将其保存到数据库中。不过好像保存不完整。
在此函数中:
public function executeUploadFile(sfWebRequest $request){
if (!$_FILES['file']['error']){
$fn = $_FILES['file']['tmp_name'];
$fh = fopen($fn,'r+');
$fc = fread($fh, filesize($fn));
mail('[email protected]','test 3',$fn.'-'.filesize($fn).'-'.strlen($fc));
fclose($fh);
move_uploaded_file($_FILES['file']['tmp_name'],dirname(__FILE__).'/'.$_FILES['file']['name']);
$q = Doctrine_Query::create()
->update('PrimhdLog')
->set('results', "'".mysql_escape_string($fc)."'")
->where("files_expected like '%".$_FILES['file']['name']."%'");
$sql = $q->getSqlQuery();
print $sql;
$uprows = $q->execute();
}else{
mail('[email protected]','uploadFile has error on file',print_r($_FILES,1));
}
return sfView::NONE;
}
我上传的文件大小(字节)分别为 4028,1658,2777。电子邮件日志和“ls -la”确认了这些大小。
但是 SELECT char_length(results), length(results), primhd_log.* FROM primhd_log
WHERE 1 分别显示大小 3900、1607、2692。
知道如何识别这个问题吗?
版本是 Symfony 1.4.6
架构:
PrimhdLog: 充当: 可加时间戳: 创建: 名称:已创建 类型:时间戳 列: id: { 类型:整数(4)、notnull: true、unique: true、primary: true、autoincrement: true } 创建者:{ 类型:整数(4) } 详细信息:{ 类型:clob(16000000),notnull: true } 提交:{ 类型:时间戳 } 提交者:{ 类型:整数(4) } 结果:{ 类型:clob(16000000) } 开始:{ 类型:时间戳 } 结束:{ 类型:时间戳 } files_expected: { 类型: clob(16000000) } 输出文件名:{ 类型:字符串(100) } 关系: 创建者:{ 类:Person,本地:created_by,foreignAlias:CreatorPRIMHDLogList } 提交者:{ class:Person,local:sublived_by,foreignAlias:SubmitterPRIMHDLogList }}
I'm receiving a zip file which I need to save to a database. However it seems to be saved incompletely.
In this function:
public function executeUploadFile(sfWebRequest $request){
if (!$_FILES['file']['error']){
$fn = $_FILES['file']['tmp_name'];
$fh = fopen($fn,'r+');
$fc = fread($fh, filesize($fn));
mail('[email protected]','test 3',$fn.'-'.filesize($fn).'-'.strlen($fc));
fclose($fh);
move_uploaded_file($_FILES['file']['tmp_name'],dirname(__FILE__).'/'.$_FILES['file']['name']);
$q = Doctrine_Query::create()
->update('PrimhdLog')
->set('results', "'".mysql_escape_string($fc)."'")
->where("files_expected like '%".$_FILES['file']['name']."%'");
$sql = $q->getSqlQuery();
print $sql;
$uprows = $q->execute();
}else{
mail('[email protected]','uploadFile has error on file',print_r($_FILES,1));
}
return sfView::NONE;
}
I have files uploaded with sizes (bytes) 4028,1658,2777 respectively. The email log and "ls -la" confirms these sizes.
However SELECT char_length(results), length(results), primhd_log.* FROM primhd_log
WHERE 1 shows sizes 3900, 1607, 2692 respectively.
Any idea how to identify this problem?
Version is Symfony 1.4.6
Schema:
PrimhdLog:
actAs:
Timestampable:
created:
name: created
type: timestamp
columns:
id: { type: integer(4), notnull: true, unique: true, primary: true, autoincrement: true }
created_by: { type: integer(4) }
details: { type: clob(16000000), notnull: true }
submitted: { type: timestamp }
submitted_by: { type: integer(4) }
results: { type: clob(16000000) }
start: { type: timestamp }
end: { type: timestamp }
files_expected: { type: clob(16000000) }
output_filename: { type: string(100) }
relations:
Creator: { class: Person, local: created_by, foreignAlias: CreatorPRIMHDLogList }
Submitter: { class: Person, local: submitted_by, foreignAlias: SubmitterPRIMHDLogList }}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的架构是什么?您将信息保存到什么数据类型? '文本'? ‘一团’?
zip 文件包含许多特殊字符,即使 mysql_escape_string 也无法捕获,如果它是一些疯狂的 ^@ 或 ^M,则只是被跳过,这会导致大小差异。
没有太多帮助,只是一个想法
What is your schema? What is the data type you are saving the info into? 'text'? 'blob'?
A zip file contains many special chars that even mysql_escape_string won't catch, if it's some crazy ^@ or ^M, that is just being skipped it would account for the size difference.
Not much help but an idea