I am working on image uploader in cakephp. I have used this link "http://www.jquery4u.com/tutorials/thumbnail-image-upload-ajaxphp/#comment-10823" to display thumb images when user clicks the browse button . Everything is working fine in fire fox but not working in other browsers(IE, chrome). This is because File properties ( i.e type, tmp_name, name) were not submitted when user clicks the submit button. Below is my code for image uploading
<?php
echo $form->create('imageupload');
echo $form->input('image_browse',array('label'=>false,'div'=>false, 'size'=>23, 'type'=>'file','class'=>'image_browse','id'=>'image_browse','onChange'=>'javascript:previewImage(this.value)));
echo $form->submit();?>
In my controller, i am using the var_dump($_FILES); to see the file parameters, but it is giving following output.
array
'image_browse' =>
array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
Even though i gave the proper image 开发者_如何学编程path, it is giving file not uploaded error. If i remove the js file link used to display thumbs, it is working good. But i want to display thumb as well as upload the file.
How to solve this issue?Thanks in advance Pushpa
Hey Buddy!
Start the form as:
<?php
echo $this->Form->create('imageupload', array('type' => 'file'));
?>
and after that create input elements
Had a similar problem
If your $_FILES and $_POST are empty, this can be due to
- the limit set by post_max_size in php.ini
- the limit set by upload_max_filesize in php.ini
Unfortunately the first limit is not reported back as an error code in $_FILES['error'].
精彩评论