Recommended Posts

I have a PW site where I had been successfully uploading png and jpeg files. Recently the file and image file fields don't save. The upload status bar completes (100%) without error but when the page with the file field is saved the uploaded file name is missing from the refreshed page.

This must be due to a site hosting change but I need more specific info like error details before I raise it with them.

The php v5.4 config has file uploads enabled and safe mode is off. 

I have tried the following to fix this without success:

  1. I have read and tried the fixes to the similar posting from Soma:  can't upload image/files problem
  2. Upgraded the PW site from 2.3 to 2.5.3. (no change)
  3. Turned on debug in config.php with no obvious error messages showing.
  4. Debugged core\WireUpload.php where I found that the recommended fixes from 1. wouldn't work because the file field is not using Ajax.

Have you got any other suggestions?

  

  • Like 1

Share this post


Link to post
Share on other sites

Memory? If Images are a little bigger it can require a great amount of memory real quick to create the thumb.

Share this post


Link to post
Share on other sites

Don't believe its memory. The pdf files I have been testing with are less than 270KB and site hosting disk space allowance is 2GB with only 163MB used.

In the associated posting the following recommendation was provided:

Edit: just added a new $config->uploadTmpDir that you can set in your /site/config.php. This will override PHP's upload_tmp_dir for ajax uploads only (I don't think we can override that on non-ajax uploads).....

Given the above and that I found that the file field on the hosted site is currently not using Ajax based uploads does anyone know how I can configure the file field/site to use Ajax?

Share this post


Link to post
Share on other sites

I have a similar problem with a website I just finished. 

Images appear in the correct directory (I see them with FTP), but they won’t get cropped or scaled and they won’t show up in frontend and backend.

I tried some of the tips I found in the forum but nothing worked…

Uploading PDF Files works fine, so I think it might be a problem with Scaling/Cropping images.

Share this post


Link to post
Share on other sites

With further analysis I have found I was wrong about the use of Ajax. The client side script in InputfieldFile.js was using Ajax based file upload but it was just not working and not returning any errors. As soon as I commented out the following code block and replaced it with InitOldSchool() both image and file uploads worked fine not using Ajax.

*	if (window.File && window.FileList && window.FileReader && $("#PageIDIndicator").size() > 0) {  
*		InitHTML5();  
*	} else {
*		InitOldSchool();
*	}

So any guess as to why Ajax based file uploads have stopped working or how I can debug this?

I have tested this on both IE, Chrome and FF with no change. It must be a hosting config issue. 

  • Like 2

Share this post


Link to post
Share on other sites

Have you added an element with ID "PageIDIndicator"?

If you remove / rename it upload should work without modifications.

Take a look at the if condition.

Share this post


Link to post
Share on other sites

I try to investigate but first I show you the errors.

The ajax return:

<br />
<b>Deprecated</b>:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent in <b>/Users/andreamontaldo/Sites/siae-promo/web/wire/core/admin.php</b> on line <b>15</b><br />
[{"error":false,"message":"Added file: dsc00181.jpg","file":"\/siae-promo\/web\/site\/assets\/files\/1023\/dsc00181.jpg","size":98458,"markup":"\n\t<li id='file_3dbec45f3f9fb3712c4ac718c1f1ba9b' class='InputfieldFileItem InputfieldImage ui-widget'>\n\t\t<p class='InputfieldFileInfo InputfieldItemHeader ui-widget ui-widget-header'>\n\t\t\t<i class='fa fa-fw fa-sort HideIfSingle'><\/i>\n\t\t\t<i class='fa fa-fw fa-caret-right HideIfMultiple'><\/i> \n\t\t\t<a class='InputfieldFileName pw-modal pw-modal-large' title='dsc00181.jpg (1623x1080)' href='\/siae-promo\/web\/gestione\/page\/image\/edit\/?id=1023&file=1023,dsc00181.jpg&rte=0&field=cover' data-buttons='#non_rte_dialog_buttons button' data-autoclose='1' data-close='#non_rte_cancel'>dsc00181.jpg <i class='fa fa-pencil ui-priority-secondary'><\/i><\/a> \n\t\t\t<span class='InputfieldFileStats'>96 kB, 1623x1080  <\/span> \n\t\t\t<label class='InputfieldFileDelete'><input type='checkbox' name='delete_cover_3dbec45f3f9fb3712c4ac718c1f1ba9b' value='1' title='Delete' \/><i class='fa fa-fw fa-trash'><\/i><\/label>\n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveBottom' href='#' title='Move to bottom'><i class='fa fa-fw fa-angle-double-down'><\/i><\/a> \n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveTop' href='#' title='Move to top'><i class='fa fa-fw fa-angle-double-up'><\/i><\/a> \n\t\t<\/p>\n\t\t<div class='InputfieldFileData ui-widget ui-widget-content'>\n\t\t\t<div class='InputfieldImagePreview'>\n\t\t\t\t<a class='InputfieldFileLink' target='_blank' href='\/siae-promo\/web\/site\/assets\/files\/1023\/dsc00181.jpg?nc=1429127148'><img height=\"50\" src=\"\/siae-promo\/web\/site\/assets\/files\/1023\/dsc00181.0x100.jpg?nc=1429127149\" alt=\"\" data-gridsize=\"50\"  \/><\/a>\n\t\t\t\t<div class='InputfieldImageActions'>\n\t\t\t\t\t<a title='dsc00181.jpg (1623x1080)' href='\/siae-promo\/web\/gestione\/page\/image\/edit\/?id=1023&file=1023,dsc00181.jpg&rte=0&field=cover' class='pw-modal pw-modal-large' data-buttons='#non_rte_dialog_buttons button' data-autoclose='1' data-close='#non_rte_cancel'><i class='fa fa-fw fa-crop'><\/i><\/a>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t<div class='InputfieldFileDescription'><label for='description_cover_3dbec45f3f9fb3712c4ac718c1f1ba9b' class='detail'>Description<\/label><input type='text' name='description_cover_3dbec45f3f9fb3712c4ac718c1f1ba9b' id='description_cover_3dbec45f3f9fb3712c4ac718c1f1ba9b' value='' \/><\/div>\n\t\t\t<input class='InputfieldFileSort' type='text' name='sort_cover_3dbec45f3f9fb3712c4ac718c1f1ba9b' value='0' \/>\n\t\t<\/div>\n\t\t\t<div class='ui-widget-content crops'><p class='description'>Thumbnails (hover to preview, click to crop)<\/p><a target='_blank' data-thumburl='\/siae-promo\/web\/site\/assets\/files\/1023\/thumbnail_dsc00181.jpg' class='crop' href='\/siae-promo\/web\/gestione\/page\/image-crop\/?filename=dsc00181.jpg&prefix=thumbnail&width=100&height=100&pages_id=1023&field=cover&modal=1'>thumbnail<\/a><\/div>\n\t<\/li>","replace":false,"overwrite":0}]

The PHP logs:

[15-Apr-2015 21:45:34 Europe/Rome] PHP Deprecated:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[15-Apr-2015 21:45:34 Europe/Rome] PHP Warning:  Cannot modify header information - headers already sent in Unknown on line 0
[15-Apr-2015 21:45:34 Europe/Rome] PHP Warning:  Cannot modify header information - headers already sent in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/admin.php on line 15
[15-Apr-2015 21:46:41 Europe/Rome] PHP Notice:  Undefined index: id in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/Process.php on line 313
[15-Apr-2015 21:46:41 Europe/Rome] PHP Notice:  Undefined index: id in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/Process.php on line 313
[15-Apr-2015 21:46:41 Europe/Rome] PHP Notice:  Undefined index: id in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/Process.php on line 313
[15-Apr-2015 21:46:41 Europe/Rome] PHP Notice:  Undefined index: id in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/Process.php on line 313
[15-Apr-2015 21:46:41 Europe/Rome] PHP Notice:  Undefined index: id in /Users/andreamontaldo/Sites/siae-promo/web/wire/core/Process.php on line 313
  • Like 1

Share this post


Link to post
Share on other sites

Roll back to php 5.5 and it works like a charm.

With PHP 5.6 I added this line to php.ini

always_populate_raw_post_data = -1 

and now the ajax upload works.

  • Like 4

Share this post


Link to post
Share on other sites

I have the same problems with PW 2.6.0 and php 5.3.9, I can't upload images (The upload status bar completes (100%) without error but when the page with the file field is saved the uploaded file name is missing from the refreshed page).

With console, I got a Javascript error, please see attached....

post-2091-0-49232400-1432633355_thumb.pn

Share this post


Link to post
Share on other sites

The listed script snippet is part of the jquery core library, which should be rather stable. Please refresh the modules in the backend and hardreload the browser to clear your cache. If the error persists, please report back.

Share this post


Link to post
Share on other sites

Same problem with me. Everything with uploding images or files is working flawlessly on mij local xampp server. I could get it partly working on my live shared hosting provider (with by the way by years never have given me any problems when trying out lot of CMS/CMF applications) with version 2.5 after the solution mentioned above at Alanp. Since version 2.6 even that is no longer working. The strange thing is that i get, just like Beate, js errors, with is not happening on mij local site. All the Apache en PHP requirements are fulfilled on both servers. The only difference: local server PHP 5.63, hosted server PHP 5.3.29. 

I can't figure out why I get javascripterrors when something is different in the PHP version.

Very pity, because I love the clearness of the PW system, wich is now nut usable for me. 

Share this post


Link to post
Share on other sites

If you see a JS error form file upload, there's an way to find out exactly what the source of the error is, at least in Chrome. 

  1. Open the developer tools in Chrome: View > Developer > Developer Tools.
  2. Click on the "Network" tab in these tools. You should see columns for "Name, Status, Type, Initiator, Size, Time, Timeline" (if you don't, drag your dev tools to be a little larger). 
  3. Drag in a file to your file field that's not working, to attempt to upload. 
  4. You'll see a new item appear at the bottom of your Network tab that looks like "?id=123", where 123 is the ID of the page you are uploading to.
  5. Click that "id?=123" item. It'll open a new panel to the right with several new tabs. Click the "Response" tab. 
  6. In this Response tab, you'll see some kind of error message, likely followed by some JSON code. 
  7. You may be able to tell what the next step is from the error message. For instance, maybe it's some 3rd party module reporting an error directly to output, or maybe it's a 403 error from Apache, indicating that mod_security is interfering with your file uploads. It could be anything. If you can't tell what to do next from the error, paste it all in here so we can get a better look and we can suggest what to try. 

Share this post


Link to post
Share on other sites

Thank you Ryan for your instruction. It deliverd me the solution for the problem.

It pointed out that there was an Apache error 406, due to my hosting providers settings. The mentioned Ajax errors were non visible in Chrome Developer Tools (all the way logical, because there are no real Jquery errors, although the console in IE shows them, but that should be incorrect).

I found the solution for the Apache error 406 here: https://www.tipsandtricks-hq.com/apache-mod-security-update-how-to-fix-error-406-or-not-acceptable-issue-259

Coding solution 1 in my .htaccess file resolved all problems with uploading files or images:

<IfModule mod_security.c>

SecFilterEngine Off

SecFilterScanPOST Off

</IfModule>

I am very very happy, and can go on with processwire.

  • Like 1

Share this post


Link to post
Share on other sites

I'm having the exact same problem. I'm using the CropImages modules (to get neat thumbnails). It's working on XAMPP offline, but doesn't work when the site is online on my server. I've tried the .htaccess trick, but it isn't working: the file gets uploaded (supposedly), reaches 100%, and then nothing happens.

I have debugging on and I get this message: "Pageimages: Removed 'images' temp file(s) for page /applications/h2so4-oleum/ - applications-h2so4.jpg, applications-h2so4-1.jpg".

I've added the temporary directory to config.php (it wasn't included there), and even manually added the directory under /assets, but no luck so far. I've changed permissions to be very lenient (for testing purposes), but that didn't seem to have any effect either.

In developer tools, I'm getting this error: "Warning: set_time_limit() has been disabled for security reasons" (and I have no idea why -- I didn't specify a time limit anywhere and don't have direct access to php.ini on my host). Any ideas on how to solve this?

Edit: something curious just happened -- I get the same error in Chrome, but unlike Firefox, the images do appear to get uploaded. (But only if you leave it on for a while, apparently.)

Edit 2: I think the problem is in the CropImage module -- I made a test field with a regular image field type and that works as expected. I got an error about ImageSizer at one point, but haven't seen it again. So there's a problem with the module. (I'm using Apeisa's latest version).

Share this post


Link to post
Share on other sites

I've removed the CropImage module and am using the default Images field. I still get problems! Specifically, I get this one: "Pageimages: Removed 'images' temp file(s) for page". I'm guessing it's perhaps some kind of permissions problem? Strangely, it sometimes *does* work in Chrome. I've never experienced something like this.

Edit: could be a server problem? Like I said, it worked fine on XAMPP. Just don't know where to look...

Share this post


Link to post
Share on other sites

I've read elsewhere that switching to OldSchool could work. However, where do I implement this?

Edit: increased PHP memory limit via PHP (in config.php). I managed to upload one picture. All others afterwards failed with the same non-error (getting stuck at 100%). It's quite frustrating. :-/

Edit 2: Apache error logs keep referring to this: "PHP Warning:  set_time_limit() has been disabled for security reasons in /sites/XYZ.com/test/wire/core/ImageSizer.php". I'm guessing that's the problem. No idea how to fix it, though. Never had this issue before.

Share this post


Link to post
Share on other sites

"Solved" the issue by commenting out the contents of the function in question (part of core). Image fields work now. I'll remove the comments when the site's been moved to its definitive location and see if the issue reappears.

Edit: and apologies for posting three times in a row. ;-)

Share this post


Link to post
Share on other sites

Similar problem here.

Refering to https://processwire.com/talk/topic/8712-imagefile-upload-problems-without-errors/?p=92979

Changing the PHP ini file does not make any difference i am afraid. 

PW V. 2.6.1 stable, any settings/permissions are identical to former installation (PW V. 2.6.0), no modules/plugins, Image Fieldtype, Debug mode is active.

Wether drag/drop or select from input leads to:

post-2270-0-48904200-1441567628_thumb.pn

Header Response within chrome dev tools:

post-2270-0-98404100-1441567625_thumb.pn

After saving the page following message appear:

post-2270-0-30631200-1441567976_thumb.pn

It seems to me, there might a bug in the js ajax code(?).

Anyone have any hints how to solve this? Would be great ;-)

Thx in advance. 

Share this post


Link to post
Share on other sites

Correction. Applying

always_populate_raw_post_data = -1

to the php.ini as a workaround do the job and enables image upload again.

This is exactly what I needed to get image uploads working on my vagrant box (scotch.box).

Edit: Had this problem on another vagrant box today, searched for the solution, and found this post—but I forgot where to find the php.ini file on scotch.box.

So here are the baby steps, future self:

  1. Connect to the box shell:
    vagrant ssh
  2. Open php.ini in vim:
    sudo vim /etc/php5/apache2/php.ini
  3. Find the right line:
    /always_populate_raw_post_data<CR>
  4. Uncomment the line:
    0x
  5. Save and quit:
    ZZ
  6. Restart Apache:
    sudo service apache2 restart
    
  7. Exit the vagrant shell:
    <C-d>
  • Like 2

Share this post


Link to post
Share on other sites

I've run into the same issue.

It isn't present at all on XAMPP with PHP v.5.5.1 and Firefox v.41.0.2, but once I transferred my site to a CentOS v.7 server running PHP v.5.5.30 (same browser) I couldn't upload images anymore until I did the "oldschool" workaround outlined by AlanP. The php.ini setting change had no effect for me.

Share this post


Link to post
Share on other sites

By now I should just assume that any bizarre issue I run into with ExpressionEngine or Processwire is being caused by ModSecurity (which I doubt anyone runs in their dev environment). I'm sure that module serves an important purpose, but man, is it ever good at creating problems that look like they're scripting errors.

I had four different web development toolbars telling me that the issue was with JqueryCore.js, specifically:

FIREFOX DEVELOPER TOOLBAR
-----------
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. JqueryCore.js:2:0
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data JqueryCore.js:2:13582

FIREBUG
-----------
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
http://[site]/wire/modules/Jquery/JqueryCore/JqueryCore.js?v=183
Line 2
...trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@"...    

CHROME
--------
Uncaught SyntaxError: Unexpected token <v.extend.parseJSON @ JqueryCore.js?v=183:2(anonymous function) @ InputfieldFile.js?v=118:200

IE11
------
SCRIPT1014: Invalid character
File: JqueryCore.js, Line: 2, Column: 13575

However, when I scoured the server logs it began to look like ModSecurity was killing the process during a 302 redirect. Disabling that particular rule through the console in cPanel WHM fixed my image upload issues immediately.

Note about the OldSchool Workaround

I have no explanation for this, but for some reason when I did the OldSchool workaround (essentially replacing the whole if statement with just InitOldSchool(); ), I got a working old school upload as a superuser, but reports from regular users that they were still getting the non-working HTML5 uploader. I had created their accounts days after I made the fix to InputfieldFile.js, so it wouldn't have been a cache issue. Strange, but something you'll want to test for if you go that route.

Share this post


Link to post
Share on other sites

Just to add my solution to this issue:

I ran into this on a Basic Hosting Package on Strato (this is one of the biggest german discount Webhosters).

None of the above workarounds worked for me, but then I found a hint in the Strato FAQ:

I needed to disable the filter for guestbook-spam in the security settings, as this was causing a 503 Apache error.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By dragan
      All of a sudden image-upload seems broken. No matter if I want to upload one single image or several images.
      Chrome console says:
      Uncaught SyntaxError: Unexpected token in JSON at position 414 at JSON.parse (<anonymous>) at Function.parseJSON (JqueryCore.js?v=1535110864:2) at XMLHttpRequest.<anonymous> (InputfieldImage.js?v=122-1535110864:1973) // File uploaded: called for each file xhr.addEventListener("load", function() { xhr.getAllResponseHeaders(); var response = $.parseJSON(xhr.responseText); // line 1973 The spinning animation GIF keeps on spinning forever...
      I thought I have seen a forum thread about such an error, but I can't find it anymore.
      If I inspect https://dev.mysite.com/backstage/page/edit/?&amp;id=11203&amp;InputfieldFileAjax=1 I only see headers, no content.
      content-type: application/octet-stream (in request header)
      in response headers:
      x-tracy-ajax: 1
      x-xss-protection: 1; mode=block
      Does anyone know what could cause this?
      PW 3.0.111 / PHP 7.2.8
    • By Mustafa-Online
      I got a field with a type of "files" named: course_file .. how can I upload it to custom directory??
    • By louisstephens
      So I was going to build a todo tracking app for myself to test/broaden my knowledge of processwire, and so far it has been taxing 😓.  My Site structure is:
      - Project One - Phase One - Task - Task - Task - Phase Two - Task - Task - Task So far it was pretty easy, I can easily foreach through the Project and get the phases with their tasks. However, it gets a bit muddled when I have more than one project as I was trying to have a dashboard where the content switches out to the selected project as opposed to accessing each project via their own url. How would yall handle this?
      My next hurdle is each task has a select field (for project status) that I want to update via ajax (for the smooth transitioning).
      Scenario: You finish a task, change the option from "new" to "completed", and an onclick changes the status drop down background to green (which I have working), but then posts/saves a field on the backend to the new option.
       
      I have a page called "Actions" set up with url segments using
      if ($config->ajax && $input->urlSegment1 == 'change-status') { //save update field on admin } However, I am a little fuzzy on how to actually pass the current page along with the new selected status to actually update the page (task). I guess I am not very far into my endeavor. Any help would be greatly appreciated.
    • By louisstephens
      So I have a project where multiple pages are sending POST data to 1 single template page.  All was working well (well, at least with one ajax post), but now I have hit a stumbling block. I figured  the "best" way to handle the request were to use url segments and then use the following in the status page:
      if ($config->ajax && $input->urlSegment1 == 'add-bookmark') { // some code here } However, this doesnt seem to really work (as I assume the the request isnt being posted to /status/ but rather to /status/add-bookmark/). What is the best way to actually handle this?
    • By louisstephens
      Currently, I have a page set up listing all child pages using a foreach loop and outputting some information (thus far, it is all gravy). However, I ran into a slight problem. I have a "button" on each item being rendered that when clicked needs to send the page id to another page for processing via ajax. I thought I could just save the item id like :
      <?php $itemId = $item->id; ?> And then encoding it below in my javascript:
      var itemId = <?php echo json_encode($itemId); ?>; var data = { itemId: itemId, }; $.ajax({ type: "POST", url: "/intra/status/", data: data, success: function(){ console.log(itemId); } }); However, it is only posting the last page's id rendered by the foreach. Have I just overlooked something simple on this?