VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Razva on October 03, 2011, 15:55:32 PM

Title: [FIXED] Cannot upload images + mimetype error + slug error
Post by: Razva on October 03, 2011, 15:55:32 PM
Hi,

We're using the latest SVN.

Please take a look at http://www.semineemures.ro/produse/sobe/sobe-lemne - click the "image", you'll see some "Matrix-style" text. :)

When uploading the image the message is:
QuoteFile /home/semineem/public_html/images/stories/virtuemart/product/3 uploaded

But if you open a product - example http://www.semineemures.ro/produse/sobe/sobe-lemne/asia-detail - the image is not there.

The filename of the image was "ASIA.jpg".

Please note that we're also receiving random images regarding:
- mimetype (can't reproduce right  now)
- something about a "slug" and some random generated number

How can we fix this?

Thanks!

LATER EDIT: the image is in the stories/virtuemart/product directory (so it did upload). Still, even if the filename is "ASIA.jpg", VM tells in the admin that the Current File is "3." and the "Displayed title" is "3". Also the path is set as "images/stories/virtuemart/product/3". I have no idea where are these numbers coming from... (3?!).
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 05, 2011, 13:40:19 PM
BUMP...
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Milbo on October 06, 2011, 21:39:57 PM
The problem with your error is, that it is afaik completly outdated, therefore try first he new version please :-)
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 06, 2011, 21:42:56 PM
Hi Milbo :)

We're using the latest SVN (svn co https://dev.virtuemart.net/svn/virtuemart/trunk/virtuemart): Checked out revision 4287.

When posted the topic, we were still using the latest SVN from that day. Is that fixed in today's version?

Cheers! :)
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Milbo on October 06, 2011, 21:51:55 PM
ahh okey,.. I didnt know that. I dont have any clue. Maybe the image file is affected with a virus?
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 06, 2011, 21:56:12 PM
Nopez... We've tried with the same images we already uploaded...

The access credentials are the same, if you wanna take a look... :)
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: jjk on October 06, 2011, 22:42:30 PM
When I look at your "Asia" product details page, the image shows correctly and the page contains the image information in the screenshot below. But you don't have a corresponding thumbnail image in the /images/shop/resized/sobe-lemne folder, which is required for the category browse pages.

The "%20" in the url is the result of a space character in your image filename.

The "3" you still might see somewhere as a filename probably is a result from a small bug in a previous version. When you upload an image name that already exists, VM2 adds a random number to the filename in order to create a unique slug. For a very short period one of the VM2 RC versions cut off the filename and just left the random number in place. And since VM2 doesn't overwrite existing filenames, you still might have that one in the database table com_virtuemart_media. Try to use 'replace thumb' or 'create thumb' to solve the missing thumbnail for the category browse page.

If an image doesn't show, but you are shure that the image file is in the correct folder, you can also try to type the exact path/filename into the 'used url/used thumb url' fields under the product image tab and click on 'Save' afterwards.



[attachment cleanup by admin]
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Milbo on October 06, 2011, 22:44:05 PM
ahh the flypage problem. My last idea was that you maybe use not everytime lowercase for the template files.

But for the image I dont have an idea. Other images work?
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: constantined on October 07, 2011, 07:50:43 AM
I suggest to replace

while (file_exists(JPATH_ROOT.DS.$path_folder.$media['name'])) {
$media['name'] = $this->file_name = $this->file_name.rand(1,9);
}

with

$this->file_name = JFile::stripExt($media['name']).'-';
while (file_exists(JPATH_ROOT.DS.$path_folder.$media['name'])) {
$this->file_name .= rand(1,9);
$media['name'] = $this->file_name.'.'.JFile::getExt($media['name']);
}
$this->file_name = $media['name'];

in /administrator/components/com_virtuemart/helpers/mediahandler.php .
It can solve problem with mimetypes.
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 07, 2011, 10:25:56 AM
I'm noticing that if I upload a new image, it works, but still VM transforms the image into a number. If I'm trying to upload a previously uploaded image, everything goes crazy.

NOTE: should I start over with a fresh installation? We really need to finish this shop, we're two weeks late, and right now we're smashing on various VM bugs/errors. If necessary we can start over...
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: constantined on October 07, 2011, 12:08:27 PM
Try to cleanup #__virtuemart_medias , #__virtuemart_category_medias and #__virtuemart_product_medias tables and virtuemart  temp image folders.
Don't forget to create backup.
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 07, 2011, 17:17:03 PM
I found a very simple way to reproduce the bug:

1) create a product, with any name
2) upload a whatever image for that product
3) save the product
----- until here everything is ok
4) create another product, with any name
5) upload THE SAME image as on step 2
6) voila, the error will occur

You can see the error in action on a fresh install - http://www.semineemures.ro/produse/finisaje/finisaje-clasice

I've used the "canaria.jpg" image for both products (Canaria AND Carousel). At the first product (Canaria (http://"http://www.semineemures.ro/produse/finisaje/finisaje-clasice/canaria-detail")) the image is right there. If you open the second product (Carousel (http://"http://www.semineemures.ro/produse/finisaje/finisaje-clasice/carousel-detail")) you'll see that the image is...not existing! Also in the admin the image is randomly renamed in a number, without any thumbnail (please see attached).

Link: http://semineemures.ro/admin
U: joomla
P: joomla

Note: when making a fresh install I received "Info: Attention dangerous database still active due config setting in file". What's this about?

[attachment cleanup by admin]
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: constantined on October 08, 2011, 08:01:40 AM
Razva, I can only see that you didn't apply hotfix from this post (http://forum.virtuemart.net/index.php?topic=91593.0#msg301249).
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 08, 2011, 08:19:08 AM
Quote from: constantined on October 08, 2011, 08:01:40 AM
Razva, I can only see that you didn't apply hotfix from this post (http://forum.virtuemart.net/index.php?topic=91593.0#msg301249).
I just did, and it did the magic! It works right now!

Still, isn't there a way to do this without interfering with Joomla's files?
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: constantined on October 08, 2011, 08:30:03 AM
It is virtuemart's, not joomla's file. I hope developers will add this to svn.
(still amazed: why they don't use git?)
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Milbo on October 08, 2011, 18:06:37 PM
hello constantined,

yes your fix is correct, thanks. Why we dont use Git? quite simpel answer, because I am happy, that the people started to learn svn. Git will follow.
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: constantined on October 09, 2011, 15:17:36 PM
Not fixed. The while loop will never start.
Quote
$mediaPure = JFile::stripExt($media['name']).'-';
$mediaExtension = JFile::getExt($media['name']); // we need ".jpg", not "jpg"

while (file_exists(JPATH_ROOT.DS.$path_folder.$mediaPure.$mediaExtension)) { // at start it checks "image-jpg" file and doesn't enter loop
   $media['name'] = $this->file_name = $mediaPure = $mediaPure.rand(1,9); // $media['name'] must looks like "image-423" ?
}
Solution:
Quote$mediaPure = JFile::stripExt($media['name']).'-';
$mediaExtension = '.'.JFile::getExt($media['name']);

while (file_exists(JPATH_ROOT.DS.$path_folder.$mediaPure.$mediaExtension$media['name'])) { // it checks "image.jpg", "image-4.jpg", "image-42.jpg" ...
   $media['name'] = $this->file_name = $mediaPure = $mediaPure.rand(1,9);
   $mediaPure .= rand(1,9);
   $media['name'] = $mediaPure.$mediaExtension;
}
$this->file_name = $media['name'];
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Milbo on October 09, 2011, 23:16:46 PM
ahh I missed the dot.

But your solution is missing that there exist maybe already a file with number on it, or? quite late here, I should stopp and start tomorrow, fresh.
Title: Re: [BUG] Cannot upload images + mimetype error + slug error
Post by: Razva on October 10, 2011, 10:46:40 AM
Hate to break the party but...what's the final fix on the current (4328) revision? :)

Later edit: seems that the problem is fixed in the latest SVN.