I'm doing an intranet for the employees of the company using ASP.NET and SQL Server, on the profile section i have an upload picture area (image field to show the picture, input to select the file, and the load button), this is working fine, the picture is loading into a folder, but, also i have the text fields where the user adds his info, this is also working great and is saving into the database, what now i want to do is that the user uploads the picture, and finish with all the text fields when he clicks the submit button to send all the fields into the database the name or the path of the picture he uploaded goes into the database too, all my textfields are being saved using an sqlDataSource with insertParameters.
Any idea how to do it?? i would prefer to do it with the front side code, since on the code behind i just have initializing the SqlDataSource1.Insert();
Do not save the images to disk, doing so will result in ugly mess sooner or later.
What you should do is to allow the user to upload the image, resize/crop the image on the server, convert the image to base64 and save the base64 string into varchar(max) column.
Because you are saving only small images(avatars), this solution should work without any problems.
Also when you fetch the image base64 string back from the DB, you can embed it straight into HTML if IE7 is not a requirement. Here is a list of browsers that support Data URI scheme
If embeding base64 into HTML doesn't work out, bulld an ASP.NET page that decodes the base64 string into an image and returns a binary response. Then utilise it in your page like this:
<img src="http://www.example.com/images.aspx?thimageDBrowID=12345" width="20" height="20"/>
If you're using SQL Server 2008 you can look into using FILESTREAM
Related
I'm using Imageresizer and jCrop to crop an uploaded file which I then put the url (shown below) back into the ImageUrl of an asp:image.
That all works fine but then I need to save that image back to the server - I can't find anything on this so I suspect the answer is very simple
/images/gallery/_temp/5_large.jpg?crop=(160,73,322,235)&cropxunits=480&cropyunits=320&width=600&height=600&scale=both
So, if you want to save it to the same server, you'll need to use C# -
ImageBuilder.Current.Build("~/images/gallery/_temp/5_large.jpg", "target_image.jpg", new Instructions("?crop=(160,73,322,235)&cropxunits=480&cropyunits=320&width=600&height=600&scale=both"));
Or, if you want to save it elsewhere, just save the HTTP response.
Hi there i need to show an image stored in the oracle database in (blob format i think).i have retrieved the image from database in dataset = dt.rows[0]["image"].how can convert the image to show it on the page.
Thanks.
In order to display it on a page, you need to serve the image as a separate resource from the web server.
Meaning, your page.aspx will have a tag with a src="your_image.aspx". In your_image.aspx, you need to clear response headers, make sure the Content-type is set correctly (image/jpg or something similar), put the contents of dt.rows[0]["image"] into a byte array and then write it out the binary image with something like Response.BinaryWrite(yourByteArray).
This is just a general outline. Use the googles for details :)
I have a web site in which users post news to site.
so i have two field in my database NewsTitle and NewsBody.
The Newsbody can have images.
What datatype should I use for NewsBody?
I don't want images loaded from image hosting site, I want images save in my database or in my web site's host.
What is the best way to implement this, should I use ajaxcontroltoolkit?
any ideas?
You can set your the datatype as varchar as the filename of your image, since all you need to know when you try to display the image is the filename. (but of course, you must already know the location of this file)
I think u can use ListView and the template field will contain asp:image.you can store the image name in the database and bind the imageUrl through the image directory in your system plus the image name.
Hii,
I m using a simple HTML Text editor by providig 'contentEditable' property of a div to true. All the formatting operations are working fine. The problem is when i copy and paste some html contents from somewhere else and try to post to DB the entire content may not post in to db because of the size limitation of the column. Is there any solution regarding this? I m using sql server 2008
What DB are you running?
The only solution to that is to choose a field type and size that's appropriate for the data you are going to be storing there; or if you can't do that save the contents in a file and store the file location in the DB.
I have a web page that displays a list of documents stored on the web site. I need to add a link next to each document that can e-mail it. By that I mean attach the entire document to the e-mail.
When clicking the e-mail link, a 'New Message' window needs to display with:
Subject line filled in with the title of the document (displayed on the web page)
Contents of the document downloaded from the web site and added as an attachment
The mail client is Outlook. The server is SharePoint (ASP.NET) which contains web services that are able to download files. JavaScript and any JS library is available for use. I'm not able to deploy additional software to the client.
What are my options and are there any references that achieve this type of functionality?
An alternative might be to put a link in the body of the message to a place where the file can be downloaded. You could even make it a web page that deletes the file after a set time or number of downloads. To be safe you would need to use "mailto:someone#somewhere.com&subject=somesubject&body="+System.Web.HttpUtility.UrlEncode(bodyStringToEncode) to generate an html safe llink
Even with the above answer about launching an email using office automation, you'd still need to first have the file sent to the client, saved in a name and location known to the server, in order to attach the file.
I can't think of a way to attach the document but you can have a link to fill in the subject and body of an email in which you could add a link to the online document.
<a href="mailto:test#test.com?subject=
[your_subject]&body=[url_encoded_content_string]">New Message</a>
You can use this function to urlencode your body text http://phpjs.org/functions/urlencode
Hope that helps,
Josh
Using the HREF mailto, you can make outlook open with the subject at least. I don't know any way to set the body nor an attachment.
From javascript there's no way to automate Outlook using OLE.
example
Taken from:
http://www.angelfire.com/dc/html-webmaster/mailto.htm