2014-05-24 14 views
1

您好,我嘗試從google chroome中的postman中獲取文件。 我試圖獲取文件參數,大小,類型。其他服務獲取yii中的文件參數

這是解決

If($_POST) 
    { 
     $document='document_from_postman.docx' 
     $size = file size of $document 
     $tip = file type of $document 


    } 
$size sent to database. 
$tip sent to database. 

的邏輯,但我不知道如何在警予控制器實現這一點,如何從郵遞員鍵值,我從來沒有使用Web服務before.How工作投入從變量例如郵遞員文件名: $文件= 'document_from_postman.docx'

回答

0

您必須使用

$file=CUploadedFile::getInstance($model,'file');

在您的控制器中。比你能獲取文件

echo $file->size; 
    echo $file->type; 

的尺寸和類型要寫入數據庫,你已經知道我想怎樣做。例如:

$file=CUploadedFile::getInstance($model,'file') 
$model->size = $file->size; 
$model->type = $file->type; 
$model->save() 
相關問題