Jump to content


Why does image upload fails?

uploading bug enterprise

  • Please log in to reply
8 replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 09 June 2017 - 05:49 AM

I followed the API and function guide for uploading from here:

https://www.groceryc.../setFieldUpload

		$crud->setFieldUpload('u_Image','assets/images/uploads','assets/images/uploads');
		$crud->setFieldUpload('u_Sig','assets/images/uploads','assets/images/uploads');

I used an old table with actual correct file path and images to test.

The image appears as a preview. But uploading a new photo

fails and an error is displayed on the console as shown

in the image below:

 

image.png



#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,096 posts
  • LocationLondon

Posted 10 June 2017 - 09:00 PM

I had a similar situation with Laravel and it seems that the CSRF protection is causing the issue.

 

This is something that I am working on to solve it as it seems that only the upload functionality has this issue. Can you please disable the CSRF protection (from application/config/config.php -> $config['csrf_protection'] = FALSE;) to see if this will work for you? If it will work then at least I will have more clue about what the issue is.

 

Thanks

Johnny


Posted Image

#3 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 11 June 2017 - 02:23 AM



I had a similar situation with Laravel and it seems that the CSRF protection is causing the issue.

 

This is something that I am working on to solve it as it seems that only the upload functionality has this issue. Can you please disable the CSRF protection (from application/config/config.php -> $config['csrf_protection'] = FALSE;) to see if this will work for you? If it will work then at least I will have more clue about what the issue is.

 

Thanks

Johnny

 

Hello Sir Johny! Thank you for answering my question.

By default the value of $config['csrf_protection'] in the config file is false. 



#4 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 13 June 2017 - 01:12 AM

Thank you for helping me out.

 

Do we have other solutions to try?



#5 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,096 posts
  • LocationLondon

Posted 14 June 2017 - 07:49 PM

Hello Lara,

 

I am copying an email that I did get from another user that did found the solution and it was only for windows that is using xampp:

 

Problem fixed. It's not a bug. I try to trace all error caused and found error undefined function finfo libraries\codeguy\upload\src\Upload\File.php line 203. Then I activate php_fileinfo extension in php.ini configuration and now file upload running well. Maybe you should add in documentation how to fix file upload problem since xampp installation doesn't have php_fileinfo activated by defaut. Thanks John :)

 

I hope the above ^ will help.

 

Thanks
Johnny


Posted Image

#6 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 15 June 2017 - 06:30 AM

Hello Lara,

 

I am copying an email that I did get from another user that did found the solution and it was only for windows that is using xampp:

 

 

I hope the above ^ will help.

 

Thanks
Johnny

 

Hello Sir Johnny!

 

Unfortunately it still doesn't work for me.  :(

Same error occurs.  :(

 

I am now trying to setup a manual installation instead of XAMPP.

I'll let you know what happens next.

 

Thanks!



#7 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 19 June 2017 - 06:07 AM

Hello Sir Johny,

 

I was finally able to do a manual setup of Apache, PHP and MySQL and run my program on it.

The same problem occurs with the upload.

 

Here is the screenshot of the details:

image.png

 

What solution do you suggest? 

 

Thanks!



#8 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 173 posts
  • LocationPhilippines

Posted 21 June 2017 - 05:35 AM

Hello again!

 

I noticed that the upload works when the supplied path of directory is:

(This is on the sample development system I sent you earlier)

        './assets/images/uploads'

but once I used:

(This is the actual system that I am developing)

       '../assets/images/uploads'

 

I need the second one because it is the actual location of the photo.

How come that it can display the image properly but fails during the upload?

By the way the CRUD that I am working on is inside an iframe.

Would that be an issue?

 

Thanks!



#9 nunenthal

nunenthal

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationFrance

Posted 03 March 2019 - 06:23 PM

Work for me width :

$crud->setFieldUpload('fichier', './assets/logos','../assets/logos');

 

And in my resize function I must use this :

 $crud->callbackAfterUpload(function ($data = null) {   
$file_uploaded =  $_SERVER['DOCUMENT_ROOT'].'/assets/logos/' . $data->filename;

$size=getimagesize($file_uploaded);

.....

 

 

It's very strange, but this work.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users