Jump to content

Problem uploading images


Michal Gancarski
 Share

Recommended Posts

Hi!

I have finally managed to start my first project in ProcessWire. Loving the simplicity and flexibility but I have stumbled upon a problem with Image field. It just does not upload anything. What happens is:

  1. Upload progress bar is going up to 100%.
  2. Folders in assets/files are properly created, with permissions set to 777.
  3. Unfortunately, no image is being uploaded as there are no files in created folders.
  4. Nothing shows in Javascript console (Chrome and Firefox), so it is not a front-end problem.

I have been searching for solution on this problem but what I have found was not helpful. I have safe_mode in PHP turned off.

The issue persists for File fields as well.

Thanks!

Link to comment
Share on other sites

Do you have debug turned on in the config.php file?

Also, add this to end of your body - at the end of your foot.inc file if that is how you have things set up:

<?php if($config->debug && $this->user->isSuperuser()) include($config->paths->adminTemplates . "debug.inc"); ?>
 

Let us know if those together produce any errors.

Link to comment
Share on other sites

Hi, Adrian!

Thanks for your reply. I have turned debugging on and added the line to my templates. I am not sure which information would be useful but I have noticed that if debug is on, uploading stops at less than 100% (depending on the size of an image). I don't think it is about the allowed sizes for file uploads - uploading stops at what seems the last step in the process.

Link to comment
Share on other sites

This could be a server-side problem.

Check the response of the ajax request sent. If you have enabled debug mode, maybe you can see the error that was throwed.

Try with smaller files or increase the following php settings:

  • post_max_size,
  • upload_max_filesize,
  • max_execution_time,
  • max_input_time,
  • memory_limit
Link to comment
Share on other sites

Just realized you already checked the js console so this probably won't help you. Anyway it might help some one else with a similar problem.

Here's a screen image of the problem i encountered and it gave the hoster a clue what caused the problem:
According to the hosting provider it was because of the mod_security setting but they couldn't be more specific than that.
Hope you get it working.
Link to comment
Share on other sites

OK, I have talked with my hosting provider, they have also read this thread. We worked a bit to solve the issue and at the moment we come up with an error generated during upload, possibly at the very end of the process:

PHP Warning: file_put_contents() [<a href='function.file-put-contents'>function.file-put-contents</a>]: Filename cannot be empty in /wire/core/Upload.php on line 128

I guess this is why progress bars stop just before the process finishes. I checked the line in Upload.php. I am unable to understand exactly what is what there but I am guessing this may be a problem with temporary folder. I have checked where the folder should be present (by printing $config->paths->tmp) and the path it showed me was /site/assets/tmp/. This folder did not exist. I have created it, switched permissions to 777 but it did not help.

Link to comment
Share on other sites

I have figured it out. Following the advice from here:

http://processwire.com/talk/topic/1002-cant-upload-imagefiles-problem/

I have added uploadTmpDir which was apparently not set in /site/config.php. Now everything works.

Taking advantage from this opportunity, I have a suggestion. Maybe ProcessWire should have this directory set by default? Is there any disadvantage to that?

  • Like 1
Link to comment
Share on other sites

Glad you figured it out. We give first choice to $config->uploadTmpDir (if set), but prefer to use PHP's 'upload_tmp_dir' setting since this will presumably be somewhere outside the web accessible structure. It sounds like in your case, the server did not have PHP's 'upload_tmp_dir' setting defined. Now we could have uploadTmpDir set to something like /site/assets/uploads/ by default. But that's under the htdocs structure (though we do block it in htaccess) and I think it's a little more secure to have the server tell us where these files should go… at least as a default.

Link to comment
Share on other sites

  • 3 years later...

when I upload images on admin area bar remain to 100%

error: on chrome console

VM797:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0parseJSON @ JqueryCore.js?v=162:16(anonymous function) @ InputfieldFile.js:171

With debug true: no errors on php

I have not updated anything and even touched or database files, how can i resolve?

Thanks

Link to comment
Share on other sites

Try looking at the Network tab (make sure it is open before you upload the image). You should end up with a line that has an error - that will be the PHP error that will give you the info to figure out what is wrong. The error you are seeing in the console is a syntax error because the ajax call is returning the real error.

My initial guess would be file/folder permissions, but if you let us know the error, we should be able to figure things out.

  • Like 3
Link to comment
Share on other sites

Try looking at the Network tab (make sure it is open before you upload the image). You should end up with a line that has an error - that will be the PHP error that will give you the info to figure out what is wrong. The error you are seeing in the console is a syntax error because the ajax call is returning the real error.

My initial guess would be file/folder permissions, but if you let us know the error, we should be able to figure things out.

Hi, thank u for your help.

I've opened Chrome Network tab, I don't see any PHP error (debug true)

I see on network tab

removeClass@JqueryCore.js?v=162:16removeClass@JqueryUI.js?v=180:587(anonymous function)@main.js?v=2:31handle@JqueryCore.js?v=162:17F@JqueryCore.js?v=162:17handle@JqueryCore.js?v=162:17k@JqueryCore.js?v=162:16

and Chrome console

VM770:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0parseJSON @ JqueryCore.js?v=162:16(anonymous function) @ InputfieldFile.js:171
JqueryCore.js?v=162:18 'webkitRequestAnimationFrame' is vendor-specific. Please use the standard 'requestAnimationFrame' instead.
 
What can I do? And the right write permission on what folder?
 
Thanks.
Link to comment
Share on other sites

do you see any notice / hint in the PW logs?

  • site/assets/logs/errors.txt
  • site/assets/logs/exceptions.txt
  • site/assets/logs/warnings.txt

errors.txt

Error Exception: Method JqueryCore::addComponents does not exist or is not callable in this context (in /home/rvocsizt/public_html/wire/core/Wire.php line 232)  #0 /home/rvocsizt/public_html/wire/modules/Jquery/JqueryCore/JqueryCore.module(39): Wire->__call('addComponents', Array) #1 /home/rvocsizt/public_html/wire/modules/Jquery/JqueryCore/JqueryCore.module(39): JqueryCore->addComponents(Array) #2 /home/rvocsizt/public_html/wire/core/Modules.php(327): JqueryCore->__construct() #3 /home/rvocsizt/public_html/wire/core/admin.php(15): Modules->get('JqueryCore') #4 /home/rvocsizt/public_html/site/templates-admin/controller.php(13): require('/home/rvocsizt/...') #5 /home/rvocsizt/public_html/site/templates/admin.php(13): require('/home/rvocsizt/...') #6 /home/rvocsizt/public_html/wire/core/TemplateFile.php(92): require('/home/rvocsizt/...') #7 [internal function]: TemplateFile->___render() #8 /home/rvocsizt/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array) #9 /home/rvocsizt/public_html/wire/core/Wi
2016-04-30 08:39:04 Error Exception: Method JqueryCore::addComponents does not exist or is not callable in this context (in /home/rvocsizt/public_html/wire/core/Wire.php line 232)  #0 /home/rvocsizt/public_html/wire/modules/Jquery/JqueryCore/JqueryCore.module(39): Wire->__call('addComponents', Array) #1 /home/rvocsizt/public_html/wire/modules/Jquery/JqueryCore/JqueryCore.module(39): JqueryCore->addComponents(Array) #2 /home/rvocsizt/public_html/wire/core/Modules.php(327): JqueryCore->__construct() #3 /home/rvocsizt/public_html/wire/core/admin.php(15): Modules->get('JqueryCore') #4 /home/rvocsizt/public_html/site/templates-admin/controller.php(13): require('/home/rvocsizt/...') #5 /home/rvocsizt/public_html/site/templates/admin.php(13): require('/home/rvocsizt/...') #6 /home/rvocsizt/public_html/wire/core/TemplateFile.php(92): require('/home/rvocsizt/...') #7 [internal function]: TemplateFile->___render() #8 /home/rvocsizt/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array) #9 /home/rvocsizt/public_html/wire/core/Wi
 
thanks
Link to comment
Share on other sites

  • 2 weeks later...

I have a image upload problem!

The ajax gif is turning and not stopping...
The image and the resized image appears in the assets/file/xxx folder...

The image-sizer.txt log file says it has resized the image (I switched debug on)

the ajax gif is still turning

When I click save... the image isn´t added to the page...
:-(

It´s an fresh pw installation...
And I tried it with several wamp servers (easynews, xampp)

Link to comment
Share on other sites

It´s an fresh pw installation...

And I tried it with several wamp servers (easynews, xampp)

  • Are you using ProcessWire 2.7.2, 2.7.3 or 3.0.17?
  • PHP Version?
  • List of any Third Party modules?
  • Example of any custom code you are using?
  • Like 1
Link to comment
Share on other sites

I have probably the same issue with an old PW 2.6 install on a shared hosting with PHP 5.5.32. The ajax upload completes with 100%, but I get Uncaught SyntaxError: Unexpected token < in the console. The problem is that the ajax request to admin/page/edit/?id=1067 ends with a 302 response code, therefore jQuery tries to parse the response of the root page, which obviously starts with <html>.

I have the directive always_populate_raw_post_data set to Off, so I think that the problem is not related to https://github.com/ryancramerdesign/ProcessWire/issues/1174 and 

The directive upload_tmp_dir is set to /tmp/ with 755 permissions.

No sign of errors in PW logs and messages.

Anyone has clues?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...