How to add picture to a product through database?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
I am using file system to save my pictures. I am trying to write the code to upload images in bulk.

At this point I have added a record in the 'Picture' table and 'Product_Picture_Mapping' table.

Also inserted the pictures in "Images" folder and "Thumbs" folder of NopCommerce. Naming convention used is
0000"id in picturetable"_0.jpeg in Images folder EX:0000139_0.jpeg
0000"id in picturetable"_"product name".jpeg & 0000"id in picturetable"_"product name"_75.jpeg in Thumbs Folder EX:0000139_xxxxx.jpeg & 0000139_xxxxx_75.jpeg

However after making all these changes the image doesn't show for the product.

I would really appreciate it if someone can help me with this issue.

Thanks in advance.
10 years ago
Do they just not render correctly or it appears they aren't even there?

You should have 0x in the PictureBinary field and image/jpeg in the MimeType for the Picture table.

Product_Picture_Mapping should be pretty straight forward assuming you have the correct ProductId and PictureId in there.
10 years ago
Thank you very much for the reply Andy.

I have "0x" in the PictureBinary field and "image/jpeg" in the MimeType. Also I have mapped the pictureId and ProductId in the Product_Picture_mapping.

The picture doesn't show for the product, it says "No Image Available".
6 years ago
ppushpala wrote:
Thank you very much for the reply Andy.

I have "0x" in the PictureBinary field and "image/jpeg" in the MimeType. Also I have mapped the pictureId and ProductId in the Product_Picture_mapping.

The picture doesn't show for the product, it says "No Image Available".



I am having the exact same problem.  Were you able to solve the issue, and how did you solve it?
6 years ago
fsr76 wrote:

I am having the exact same problem.  Were you able to solve the issue, and how did you solve it?

Hi,

OP's question was regarding, trying to write the code to upload images in bulk.
Are you looking for the same? or could you explain what did you try?
6 years ago
Divyang wrote:

I am having the exact same problem.  Were you able to solve the issue, and how did you solve it?
Hi,

OP's question was regarding, trying to write the code to upload images in bulk.
Are you looking for the same? or could you explain what did you try?


I am just trying to upload one photo.  I've set the PictureBinary column to 0x

The file name is in the correct format.  I have access to the server to see that everything is in the correct place.

All else looks correct compared to other images uploaded through the nop Admin.

But it doesn't work when I upload image and insert into the database through classic ASP.
6 years ago
fsr76 wrote:
But it doesn't work when I upload image and insert into the database through classic ASP.


If you're using custom code to upload images, just check all aspect things:

- Product picture record available to Product_Picture_Mapping table.
- Picture available in Picture table.
- And uploaded picture file name should be {picture id in 0000000 format}_0.{extension} format:  


string fileName = string.Format("{0}_0.{1}", pictureId.ToString("0000000"), lastPart);
6 years ago
Divyang wrote:
But it doesn't work when I upload image and insert into the database through classic ASP.

If you're using custom code to upload images, just check all aspect things:

- Product picture record available to Product_Picture_Mapping table.
- Picture available in Picture table.
- And uploaded picture file name should be {picture id in 0000000 format}_0.{extension} format:  


string fileName = string.Format("{0}_0.{1}", pictureId.ToString("0000000"), lastPart);


I am uploading a picture using classic asp to be used with a custom plugin designed for nopCommerce.  

When I use the nopCommerce plugin's admin to upload an image, I see a row added to the Picture table when the image is uploaded.

In the nopCommerce plugin's database table, I see a column that references the Picture Id, and the correct Picture Id shows up.

Picture file format in my version of Nop Commerce looks like 0001035.jpeg for full size and 0001035_100.jpeg for thumbnails.
6 years ago
fsr76 wrote:

I am uploading a picture using classic asp to be used with a custom plugin designed for nopCommerce.  

When I use the nopCommerce plugin's admin to upload an image, I see a row added to the Picture table when the image is uploaded.

In the nopCommerce plugin's database table, I see a column that references the Picture Id, and the correct Picture Id shows up.

Picture file format in my version of Nop Commerce looks like 0001035.jpeg for full size and 0001035_100.jpeg for thumbnails.


Which version are you using?
If you're using a custom plugin, I recommend to use nopCommerce services in your plugin which makes your job easier.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.