0
            $model = new XUploadForm;
            $model->file = CUploadedFile::getInstance( $model, 'file' );
            //We check that the file was successfully uploaded
            if( $model->file !== null ) {
                //Grab some data
                $model->mime_type = $model->file->getType( );
                $model->size = $model->file->getSize( );
                $model->name = $model->file->getName( );
                $file_extention = $model->file->getExtensionName( );
                //(optional) Generate a random name for our file
                $file_tem_name = md5(Yii::app( )->user->id.microtime( ).$model->name);
                $file_thumb_name = $file_tem_name.'_thumb.'.$file_extention;
                $file_image_name = $file_tem_name.".".$file_extention;
                if( $model->validate( ) ) {
                    //Move our file to our temporary dir
                    $model->file->saveAs( $path.$file_image_name );
                    if(chmod($path.$file_image_name, 0777 )){

     //                 Yii::import("ext.EPhpThumb.EPhpThumb");
                    // $thumb_=new EPhpThumb();
                 //      $thumb_->init();
                    // $thumb_->create($path.$file_image_name)
                    //  ->resize(110,80)
                    //  ->save($path.$file_thumb_name); 


                    }
                    //here you can also generate the image versions you need 
                    //using something like PHPThumb





                    //Now we need to save this path to the user's session
                    if( Yii::app( )->user->hasState( 'images' ) ) {
                        $userImages = Yii::app( )->user->getState( 'images' );
                    } else {
                        $userImages = array();
                    }
                     $userImages[] = array(
                          "filename" => $file_image_name,
                        'size' => $model->size,
                        'mime' => $model->mime_type,
                        "path" => $path.$file_image_name,
                       // "thumb" => $path.$file_thumb_name,
                    );
                    Yii::app( )->user->setState('images', $userImages);      
                    //Now we need to tell our widget that the upload was succesfull
                    //We do so, using the json structure defined in
                    // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
                    echo json_encode( array( array(
                            "type" => $model->mime_type,
                            "size" => $model->size,
                            "url" => $publicPath.$file_image_name,
                            //"thumbnail_url" => $publicPath.$file_thumb_name,
                            //"thumbnail_url" => $publicPath."thumbs/$filename",
                            "delete_url" => $this->createUrl( "upload", array(
                                "_method" => "delete",
                                "file" => $file_image_name
                            ) ),
                            "delete_type" => "POST"
                        ) ) );

上記のコードは正しい応答 [{"type":"image/jpeg","size":2266,"url":"/uploads/tmp/0b00cbaee07c6410241428c74aae1dca.jpeg","delete_url":"/api/imageUpload/] を返します。 upload?_method=delete&file=0b00cbaee07c6410241428c74aae1dca.jpeg","delete_type":"POST"}]

しかし、次のコメントを外すと

         //     Yii::import("ext.EPhpThumb.EPhpThumb");
                // $thumb_=new EPhpThumb();
             //      $thumb_->init();
                // $thumb_->create($path.$file_image_name)
                //  ->resize(110,80)
                //  ->save($path.$file_thumb_name);   

それは私に壊れた応答を与えました:

Mac OS X 2��ATTR�dA��Y�Y.com.apple.quarantine0001;50655994;Google\x20Chrome.app;2599ECF9-69C5-4386-B3D9-9F5CC7E0EE1D|com.google.Chromeこのリソース フォークは意図的に空白のままにされています ��[ {"type":"image/jpeg","size":1941,"url":"/uploads/tmp/409c5921c6d20944e1a81f32b12fc380.jpeg","delete_url":"/api/imageUpload/upload?_method=delete&file=409c5921c6d20944e1a81f3380b12fc jpeg","delete_type":"POST"}]

4

1 に答える 1

1

MacOS があなたのダウンロードext.EPhpTHumb.EPhpThumbまたはそのライブラリの 1 つを検疫したと思います。

プラグインがインストールされている場所がわかっている場合はxattr -d com.apple.quarantine <filename>、ターミナルからプラグインを削除するか、Googleremove mac os x quarantine statusで別の方法を探してください。

于 2012-09-30T09:34:38.680 に答える