Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

I have created a project where I have crystal reports also.
I enter images from front end side and it gets stored in database in binary data.

This is done otherwise my images werent getting displayed in gridview or crystal report.

So all the images are of file type.

When i run from my local machine localhost...asp.net server, its showing all the images perfectly and running fine.

But as soon as I have uploaded all my files in server hosting,

My project is running but the images in file type binary data are not showing in gridview

The hosting website saying that the images should be converted to .jpg or .png

But its working on my localhost server, then why those images are not displaying in their hosting server?

Can anyone please tell me? as my website is already in live and these are the errors coming

Thanks
Sudeshna
Posted
Comments
F-ES Sitecore 18-May-15 7:51am    
When you View Source what does the <img> tag look like for the images?

1 solution

Your local environment is not the same as your hosting environment. On your local environment you can easily add or remove features or functions. On your hosting environment you are bound to their rules and policy terms. You have to abide them in order to use their system to host your application (even though you pay them!).

If hosting server team asks you to use only files for images and not binary data for them. You are required to do so. There is no other option for you to use in this context. No matter what other patch you can create on your local environment.

The following code converts the (valid!) binary data to a file, using the MIME type being passed to the response. You will get a file in the response. Try this,

C#
Response.ContentType = file.MimeType; // or even plain image MIME as string
Response.BinaryWrite((byte[])file.FileContent);


You can write this code in a separate ASP.NET server-side file. Then you can execute the code to get an image which can be then used in your process for further processes.

For more on this topic, please read: http://www.mikesdotnetting.com/article/148/save-and-retrieve-files-from-a-sql-server-ce-database-with-webmatrix[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900