Yii Framework Forum: Image not get upload - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Image not get upload

#1 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 07 December 2017 - 06:02 AM

Hello,

I had stuck in a prob that, some images alone not get uploaded in php (Using Yii1 framework). I thought it may be a memory problem so I had tried php.ini file (Changed mem size) but no luck.
Any help regards will be helpful.

Thanks Sally.
0

#2 User is offline   Fabrizio Caldarelli 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,062
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 07 December 2017 - 06:08 AM

Post code. Have you added enctype in form tag?

<?php
use yii\widgets\ActiveForm;
?>

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>

    <?= $form->field($model, 'imageFile')->fileInput() ?>

    <button>Submit</button>

<?php ActiveForm::end() ?>


taken from: http://www.yiiframew...ring-file-input
Yii2 by example: my book about Yii2
https://www.packtpub...nt/yii2-example
0

#3 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 07 December 2017 - 06:11 AM

View PostFabrizio Caldarelli, on 07 December 2017 - 06:08 AM, said:

Post code. Have you added enctype in form tag?

<?php
use yii\widgets\ActiveForm;
?>

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>

    <?= $form->field($model, 'imageFile')->fileInput() ?>

    <button>Submit</button>

<?php ActiveForm::end() ?>


taken from: http://www.yiiframew...ring-file-input


Images are getting upload yaar, but some images alone not get uploaded.
0

#4 User is offline   Fabrizio Caldarelli 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,062
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 07 December 2017 - 06:16 AM

Check server error log
Yii2 by example: my book about Yii2
https://www.packtpub...nt/yii2-example
0

#5 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 07 December 2017 - 06:23 AM

Will u tell me how to check error log?? (I had some doubts so)
0

#6 User is offline   Fabrizio Caldarelli 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,062
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 07 December 2017 - 06:26 AM

check apache error.log (usally in /var/log/apache2/errors.log or similarly)
Yii2 by example: my book about Yii2
https://www.packtpub...nt/yii2-example
0

#7 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,490
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 December 2017 - 06:45 AM

you can also check your log under runtime/logs/app.log
0

#8 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 07 December 2017 - 07:52 AM

Not getting any errors. I had checked log too.
0

#9 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,490
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 December 2017 - 10:05 AM

weird ... without looking at code we can't really help you much, try debugging it put var_dump to dump your $_FILES and $_POST inspect your input.

Also if you are doing processing (creating thumbnails, moving to s3) on file uploads, it might be your temp files are deleted by the OS before you get to process them.
0

#10 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 08 December 2017 - 06:35 AM

First of all thanks for the response, I had checked the temp file name , there I got as {fail:7}. then I had print the uploaded file $_FILES['file'] there I got

Array
(
    [name] => asdfg.jpg
    [type] => 
    [tmp_name] => 
    [error] => 7
    [size] => 0
)


Any help :unsure:
0

#11 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,490
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 08 December 2017 - 07:16 AM

I think its related to permissions


http://php.net/manua...load.errors.php
0

#12 User is offline   chiku 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-October 17

Posted 08 December 2017 - 07:36 AM

View Postalrazi, on 08 December 2017 - 07:16 AM, said:

I think its related to permissions


http://php.net/manua...load.errors.php



I had already checked all these through Google but could not get any solutions, I have found the error (Hope will found the solution too). Anything else??
For information I had given a try to change upload & Memory sizes in php.ini file and restarted apache but no changes.
0

#13 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,490
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 08 December 2017 - 07:44 AM

why don't you try and set your upload_tmp_dir in php.ini to something other then /tmp perhaps /home/user/tmp
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users