cakePHP or PHP with Plupload
I upload file = Plupload开发者_如何学编程 . I checked variables $_FILES
, $_POST
, $this->data
, all are empty and !isset
Please help me
function mod_uploadImg($id = null){
if (!$id){
return false;
}
if (!empty($_POST)){
CakeLog::write('activity', 'file exist');
}
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])){
CakeLog::write('activity', 'file exist');
}
if (!empty($this->data)){
CakeLog::write('activity', '$this->data');
}
if (!empty($_FILES)){
CakeLog::write('activity', '$_FILES');
}
}
I have put multipart/form-data in form ( although script seem dont must put )
Did you put
enctype="multipart/form-data"
in your form declaration?
The problem is because you are using Ajax file upload. Ajax file upload actually created a hidden tag where there is normal form with file upload element.
This is the root of the problem. iframe look like a separate page and Firebug cannot handle the post of this request. Also the fields probably are totally different than Cake's convention.
I had the same problem in the past and I struggled with the same thing. :) My advise - use normal upload.
Use: // Read binary input stream and append it to temp file $in = fopen("php://input", "rb");
精彩评论