开发者

zip file saves incomplete with doctrine::createquery->update()

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('me@myemail.com','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('me@myemail.com','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 }}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜