Jump to content

Image upload weird issue


Soma
 Share

Recommended Posts

I recently started a new project using PW2.2.

I now epxerience strange issues with image upload. It doesn't finish with the status upload bar... but after saving/refreshing it's uploaded anyway. So the only error/warning I see is in firebug.

first this one this:

<b>Warning</b>: rename(/tmp/WireUploadYsln1M,/home/bagshop/www/dev.bag-shop.ch/site/assets/files/1049/bag-maria-rot.jpg) [<a href='http://ch2.php.net/manual/en/function.rename.php'>function.rename.php</a>]: Operation not permitted in <b>/home/bagshop/www/dev.bag-shop.ch/wire/core/Upload.php</b> on line <b>233</b><br />

[{"error":false,"message":"Added file: bag-maria-rot.jpg","file":"\/site\/assets\/files\/1049\/bag-maria-rot.jpg","size":245876,"markup":"\n\t<li class='InputfieldFile InputfieldImage ui-widget'>\n\t\t<p class='InputfieldFileInfo ui-widget ui-widget-header'>\n\t\t\t<span class='ui-icon ui-icon-arrowthick-2-n-s'><\/span>\n\t\t\t<span class='InputfieldFileName'>bag-maria-rot.jpg<\/span> \n\t\t\t<span class='InputfieldFileStats'>• 240 kb • 920x840<\/span> \n\t\t\t<label class='InputfieldFileDelete'><input type='checkbox' name='delete_product_image_177d172d1ee7e8c9f8e5d315ce45cc98' value='1' \/><span class='ui-icon ui-icon-trash'>Delete<\/span><\/label>\n\t\t<\/p>\n\t\t<p class='InputfieldFileData ui-widget ui-widget-content'>\n\t\t\t<a class='InputfieldFileLink' target='_blank' href='\/site\/assets\/files\/1049\/bag-maria-rot.jpg'><img src='\/site\/assets\/files\/1049\/bag-maria-rot.0x100.jpg' alt='bag-maria-rot.jpg' \/><\/a>\n\t\t\t<label class='InputfieldFileDescription infield'>Description<input type='text' name='description_product_image_177d172d1ee7e8c9f8e5d315ce45cc98' id='description_product_image_177d172d1ee7e8c9f8e5d315ce45cc98' value='' \/><\/label>\n\t\t\t<input class='InputfieldFileSort' type='text' name='sort_product_image_177d172d1ee7e8c9f8e5d315ce45cc98' value='0' \/>\n\t\t<\/p>\n\t<\/li>","replace":true}]

and then right after this:

JSON.parse: unexpected character

...unction(h.promise)?h.promise().then(d.resolve,d.reject) :D[g](h)}):b[a](d[g])})})...

It tried in crhome, safari, ff ... always same procedure.

What's going on?

Link to comment
Share on other sites

I'm wondering if the server has safe_mode or open_basedir restrictions? I can add a '@' to the front of the rename statement in Upload.php to suppress that error message, but am curious how the file is getting through if that rename is failing.

Also, is this on a stock installation, or are there any non-core modules installed?

Link to comment
Share on other sites

Thanks I'll take a look at the php info. Which modules are installed? Since there have been a lot of changes committed in 2.2, it's good for me to know the full details of especially the ProcessWire environment and what modules may be coming in to play.

Link to comment
Share on other sites

  • 1 month later...

I've got the same issue on one of my servers :(

What I have noticed, and I can't pin this down, is that I have the following error before any other page output in the admin when I'm editing a page and viewing the page source:

<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/home/mysite/public_html/dev/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module</b> on line <b>78</b><br />

I only mention it as I've not been able to track down what that is (uninstalled all but the base modules) and I wonder if this output is interfering somehow?

It's worth noting that the site is an exact replica of my local copy and image uploads work there so it's more likely the environment. I'll grab a phpinfo() output and PM you ryan.

Link to comment
Share on other sites

Pete that error message you posted is very likely the issue. If you've got an error consistently being displayed, that will interfere with the ability of any ajax request to complete... the resulting JSON would be unparseable. I looked at line 78 of InputfieldPageAutocomplete.module and I'm not quite sure how it could generate that error. Can you double check that line 78 of that file is the same as this in your installation?

foreach($this->value as $page_id) {
   $page = $this->pages->get((int) $page_id);
   if(!$page || !$page->id) continue; // THIS IS LINE 78
   $out .= $this->renderListItem($page->get($this->labelFieldName), $page->id);
}

I am thinking that somehow your installation must be different, because it should be impossible (from what I can tell) for the statement at line 78 to produce that particular error. Please let me know what you find?

Link to comment
Share on other sites

Mine seems identical:

foreach($this->value as $page_id) {
  $page = $this->pages->get((int) $page_id);
  if(!$page || !$page->id) continue;
  $out .= $this->renderListItem($page->get($this->labelFieldName), $page->id);
 }

It turns out that that same text does appear in the source on my local server, but I can successfully upload images on my local server (same code - synchronised all the files today). I guess that they're two unrelated issues in that case?

Oh, just spotted this weirdness in Firebug (the two errors are obviously it trying to upload the image). Not sure why that URL would throw a 404 as that's obviously the page I'm viewing - unless of course it is prepending my error message above to any JSON output?

post-1-0-53137600-1331292827_thumb.png

Link to comment
Share on other sites

The source of the error appearing at the beginning of my code was a PageAutocomplete field with a custom selector - template=template1|template2 that was set to:

"Single page (Page) or empty page (NullPage) when none selected".

Presumably this shouldn't return an error though when viewing the page edit screen? The message goes away now when I change it to "Single page (Page) or boolean false when none selected", but I'd prefer it to be a NullPage that's returned as my code is already set up to use that.

That's one thing solved, but it still won't let me upload images on the live server (which I suspected would be the case since it does locally :().

Link to comment
Share on other sites

Pete, I'm still really confused about how that line 78 is throwing a "trying to get property of non-object" error. It really shouldn't matter if it says "single page or boolean false" or "single page or NullPage". Line 78 doesn't deal in that, and it's just a really unusual error. So I'm really curious to know what exactly $page is in that instance. It's apparently non-zero, non-object, which is something that $pages->get() technically shouldn't be able to return. Can you try adding this before line 78?

var_dump($page); exit(); 

And see what it tells you that it is?

Btw I don't see anything in your phpinfo that looks like a problem.

Link to comment
Share on other sites

It sounds like it really is a Page object then, as it should be. The question then is why PHP is throwing a "not object" error. I'm wondering about the eAccelerator that your phpinfo said is installed. I have a feeling that line 78 isn't really line 78, and that it's line 78 of a cached file or something. I look forward to getting a closer look at the install (per your PM).

Link to comment
Share on other sites

  • 1 year later...

That could be. It doesn't look like AdminBar is yet confirmed compatible with 2.3. There's a good chance there's a JS error occurring. 2.3 uses significantly newer versions of both jQuery and jQuery UI, so JS errors are the most obvious places to look (and usually the simplest issues to resolve). Are you seeing anything in your error console? (In Chrome: View > Developer > Javascript Console).

Link to comment
Share on other sites

Doesn't look like an AdminBar issue to me. I Did a really quick test with 2.3 & AdminBar and everything seems to work great. Was able to upload images, edit descriptions and reorder images right there before saving. Using MAMP with PHP 5.4.4.

  • Like 1
Link to comment
Share on other sites

Hmm, now I seem to be having the issue when not using adminbar as well. It is showing up in the Chrome developer tools as:

<exception>: SyntaxError
get stack: function () { [native code] }
message: "Unexpected token <"
set stack: function () { [native code] }
__proto__: Error
t: "<script type="text/javascript">↵		var preview = false;↵		$("#wrap_preview").

I'm not really sure what that all means...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...