Keyword

Adding Item image fails (image prefix error?)

More
15 years 8 months ago #69809 by tommy huang
Replied by tommy huang on topic Adding Item image fails (image prefix error?)
This is the file I'm trying to upload which I think is just normal jpg photo.
Thank you for your help...

Lefteris Kavadas said:Hi. Can you please attach one image file that fails?
Rolf Erik Paulsen said:After a lot of debugging, I have managed to locate where the code fails... and a way around it.. class.upload.php in /administrator/components/com_k2/lib returns 'incorrect_file'.
This only happens for the first original file that is to be saved under the /src folder, this also causes the file-name to not be generated (returned) correctly. The /cache images are saved correctly, but without file-name which is not returned from the original file.

For the first file, this is the metadata inside class.upload.php process() method:
this->file_src_mime: audio/x-mod

In the following process-method loop check for mime values:
<br/>
foreach($this-&gt;allowed as $k =&gt; $v) {<br/>
$log-&gt;lwrite(' checking '.$k.' =&gt; '.$v);<br/>
list($v1, $v2) = explode('/', $v);<br/>
if (($v1 == '*' &amp;&amp; $v2 == '*') || ($v1 == $m1 &amp;&amp; ($v2 == $m2 || $v2 == '*'))) {<br/>
$log-&gt;lwrite('one is allowed...');<br/>
$allowed = true;<br/>
break;<br/>
}<br/>
}<br/>
This produces the following log:
checking 0 =&gt; image/*

For the other generated files _Generic.jpg, _L.jpg etc... about twenty mime-values are looped through, but only one for the first...

By bypassing the mime-check I get the upload to work correctly... but not the best solution...
if (!$allowed &amp;&amp; 1 &lt; 0) { // Make sure this never happens....
$this-&gt;processed = false;
$this-&gt;error = $this-&gt;translate('incorrect_file');
} else {
$this-&gt;log .= '- file mime OK : ' . $this-&gt;file_src_mime . '';
}

Again, I reiterate that the original code works fine on my xampp server on my windows machine.

Does that help you guys that work with this code? Do you have any idea as to why the mime-check fails (I try uploading both .png and .jpg files).
Attachments:

Please Log in or Create an account to join the conversation.

  • ROLF ERIK PAULSEN
  • ROLF ERIK PAULSEN's Avatar Topic Author
  • Offline
  • New Member
More
15 years 8 months ago #69810 by ROLF ERIK PAULSEN
Replied by ROLF ERIK PAULSEN on topic Adding Item image fails (image prefix error?)
Hi Tommy,
as Lefteris said this is most likely due to failure of mime-detection on certain systems. I have not been able to fix this, but I have found a workaround which means disabling the mime-detection. Not a perfect solution, but the site works now.

Short and hopefully concise description as to what to try can be found here:
k2community.joomlaworks.gr/forum/topics/problems-uploading-video-and?page=1&commentId=3536014%3AComment%3A5332&x=1#3536014Comment5332

Rolf

tommy huang said:This is the file I'm trying to upload which I think is just normal jpg photo. Thank you for your help...

Lefteris Kavadas said:Hi. Can you please attach one image file that fails? Rolf Erik Paulsen said:After a lot of debugging, I have managed to locate where the code fails... and a way around it.. class.upload.php in /administrator/components/com_k2/lib returns 'incorrect_file'. This only happens for the first original file that is to be saved under the /src folder, this also causes the file-name to not be generated (returned) correctly. The /cache images are saved correctly, but without file-name which is not returned from the original file.

For the first file, this is the metadata inside class.upload.php process() method:
this-&gt;file_src_mime: audio/x-mod

In the following process-method loop check for mime values:
<br/>
foreach($this-&gt;allowed as $k =&gt; $v) {<br/>
$log-&gt;lwrite(' checking '.$k.' =&gt; '.$v);<br/>
list($v1, $v2) = explode('/', $v);<br/>
if (($v1 == '*' &amp;&amp; $v2 == '*') || ($v1 == $m1 &amp;&amp; ($v2 == $m2 || $v2 == '*'))) {<br/>
$log-&gt;lwrite('one is allowed...');<br/>
$allowed = true;<br/>
break;<br/>
}<br/>
}<br/>
This produces the following log:
checking 0 =&gt; image/*

For the other generated files _Generic.jpg, _L.jpg etc... about twenty mime-values are looped through, but only one for the first...

By bypassing the mime-check I get the upload to work correctly... but not the best solution...
if (!$allowed &amp;&amp; 1 &lt; 0) { // Make sure this never happens....
$this-&gt;processed = false;
$this-&gt;error = $this-&gt;translate('incorrect_file');
} else {
$this-&gt;log .= '- file mime OK : ' . $this-&gt;file_src_mime . '';
}

Again, I reiterate that the original code works fine on my xampp server on my windows machine.

Does that help you guys that work with this code? Do you have any idea as to why the mime-check fails (I try uploading both .png and .jpg files).

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #69811 by tommy huang
Replied by tommy huang on topic Adding Item image fails (image prefix error?)
Thank you for your reply but what should I do after changing the file? Because the outcome is still the same after I changed the file. I've tried to restart the web or even restart my mac and nothing different happened...

Thank you for your patience in advance...

Rolf Erik Paulsen said:Hi Tommy, as Lefteris said this is most likely due to failure of mime-detection on certain systems. I have not been able to fix this, but I have found a workaround which means disabling the mime-detection. Not a perfect solution, but the site works now.

Short and hopefully concise description as to what to try can be found here:
k2community.joomlaworks.gr/forum/topics/problems-uploading-v...

Rolf

tommy huang said:This is the file I'm trying to upload which I think is just normal jpg photo. Thank you for your help...
Lefteris Kavadas said:Hi. Can you please attach one image file that fails? Rolf Erik Paulsen said:After a lot of debugging, I have managed to locate where the code fails... and a way around it.. class.upload.php in /administrator/components/com_k2/lib returns 'incorrect_file'. This only happens for the first original file that is to be saved under the /src folder, this also causes the file-name to not be generated (returned) correctly. The /cache images are saved correctly, but without file-name which is not returned from the original file.
For the first file, this is the metadata inside class.upload.php process() method:
this-&gt;file_src_mime: audio/x-mod

In the following process-method loop check for mime values:
<br/>
foreach($this-&gt;allowed as $k =&gt; $v) {<br/>
$log-&gt;lwrite(' checking '.$k.' =&gt; '.$v);<br/>
list($v1, $v2) = explode('/', $v);<br/>
if (($v1 == '*' &amp;&amp; $v2 == '*') || ($v1 == $m1 &amp;&amp; ($v2 == $m2 || $v2 == '*'))) {<br/>
$log-&gt;lwrite('one is allowed...');<br/>
$allowed = true;<br/>
break;<br/>
}<br/>
}<br/>
This produces the following log:
checking 0 =&gt; image/*

For the other generated files _Generic.jpg, _L.jpg etc... about twenty mime-values are looped through, but only one for the first...

By bypassing the mime-check I get the upload to work correctly... but not the best solution...
if (!$allowed &amp;&amp; 1 &lt; 0) { // Make sure this never happens....
$this-&gt;processed = false;
$this-&gt;error = $this-&gt;translate('incorrect_file');
} else {
$this-&gt;log .= '- file mime OK : ' . $this-&gt;file_src_mime . '';
}

Again, I reiterate that the original code works fine on my xampp server on my windows machine.

Does that help you guys that work with this code? Do you have any idea as to why the mime-check fails (I try uploading both .png and .jpg files).

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #69812 by Allan Mouawad
Replied by Allan Mouawad on topic Adding Item image fails (image prefix error?)
Hi guys,

I had the same issues here. When I tried to upload a file directly to an item from the images tab, it would save but when I went back to the tab it didnt have the image saved. I've tried the code conversion but that didn't work.

The only way I can get this to work is to change the media/k2/items/cache directories permission from 755 to 757. For some reason it requires a write capability for all users to be able to upload files correctly.

This is on a fresh install of Joomla 1.5 with K2 v2. I needed to be able to upload images from the 'images' tab in an item because that's the only way I can get the RokStories module to show stories from K2.

Hope it helps! Gotta keep looking for a way so I don't have to give 757 permissions to that folder... if anyone knows a way please fill me in!

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #69813 by Tito Bustillo
Replied by Tito Bustillo on topic Adding Item image fails (image prefix error?)
Any solution?? I tried in different hours, chmodding media dir to 757, and I cant upload images. I only could upload one image and then, no more. Its frustrating...

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #69814 by xbow
Did anyone check on the size of the image...i experience this as well if the image size is greater than what is supported ...and the frustrating part is it doesn't give error message...

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #69815 by piperchick
Replied by piperchick on topic Adding Item image fails (image prefix error?)
I have had the same problem in 2.2 stable.

My php.ini will allow up to 12 MB, and I am bale to upload via media manager or JCE. K2 image tab is the problem. I can insert an image in an article, but not as the default image for an article. In fact, the "browse" option to pull an image off the server results in a blank page, even though the image is there. K2 can't seem to process anything over about 1.5 mb (not sure of the *exact* size where it gives up).

I am glad I am not the only person experiencing this. I have tried all the tips her, and created a new install, but no luck.

I agree an error message is more helpful than a message telling you that you have sucessfully saved the item, or the more frustrating blank page.


xbow said:Did anyone check on the size of the image...i experience this as well if the image size is greater than what is supported ...and the frustrating part is it doesn't give error message...

Please Log in or Create an account to join the conversation.

More
15 years 1 week ago #69816 by Tito Bustillo
Replied by Tito Bustillo on topic Adding Item image fails (image prefix error?)
My solution was: create in my computer the files, rename it to the name of the file created by K2, and then upload to cache folder with the _S, _M, _XL end...dirty, but it works.

Please Log in or Create an account to join the conversation.

More
14 years 10 months ago #69817 by Jan Visser
Replied by Jan Visser on topic Adding Item image fails (image prefix error?)
If you have problems with rights you might want to change your umask. This all depends on the webserver you use. If your site runs at your providet, you most probably can not change the umask.

If you run Ubuntu/Debian you can add "umask 002" to /etc/apache2/envvars en restart apache2.

I highly recommend you do not change umask if you don't know what you are doing. Failing to do it correctly may comprimise security.

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #69818 by Juan
I'm getting the blank page after trying to save an image too...in a production environment!
I really need this working...I've tried all solutions posted here, but no results...
I came up to think there's something wrong with the url and its variables, as the blank page has the bare administrator path
any progress on this lately?

Please Log in or Create an account to join the conversation.

  • Carlos Arámburu Iturbide
  • Carlos Arámburu Iturbide's Avatar
  • Offline
  • New Member
More
14 years 9 months ago #69819 by Carlos Arámburu Iturbide
Replied by Carlos Arámburu Iturbide on topic Adding Item image fails (image prefix error?)
Hi there,

I would like to know if there´s any way to add caption to the images in an article´s gallery. I already added the caption via ImageBrowser Component but it won´t display nothing once I have a look at it on the article.

Thanks in advance.

PS: I use the free version of SIG Plugin.

Please Log in or Create an account to join the conversation.

More
14 years 4 months ago #69820 by Filipe Costa
Replied by Filipe Costa on topic Adding Item image fails (image prefix error?)
Hi all!

I found a solution to this problem for me...only .jpg images works! When i tried to upload .png then the result was like described in this topic...then i change the extension of the image to .jpg and it works!

 

I hope that this help some of you...

 

Best regards,

Filipe Costa

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum