473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Image upload question

I'm trying by means of a FileUpload control and and "Apply" button, brwosong
my local folders for a picture file loading (Apply button) and displaying the
(local) picture (jpg, gif, ..) file. I don't want the local file to be saved
on the server but displayed on my webform and if ok be stored in my database
together with other related info.
I googled and found some example .. but not exactly what i want to achieve.

Anyone can give me a hint where to start?

Sep 24 '08 #1
4 1047
Hello guy,

What you need to do is upload in to server when you click ok. Example is
there http://www.beansoftware.com/ASP.NET-...-Database.aspx

So, what is the problem?!

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
:: http://twitter.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
gI'm trying by means of a FileUpload control and and "Apply" button,
gbrwosong
gmy local folders for a picture file loading (Apply button) and
gdisplaying the
g(local) picture (jpg, gif, ..) file. I don't want the local file to
gbe saved
gon the server but displayed on my webform and if ok be stored in my
gdatabase
gtogether with other related info.
gI googled and found some example .. but not exactly what i want to
gachieve.
gAnyone can give me a hint where to start?
g>
Sep 25 '08 #2
Thanks for the info.

I want, before storing the picture in the db, already display the image on
the webform and save to the db when all other info has been entered. If I'm
right the example link you provided doesn't handle this displaying of the
image before storing to the db?!

Regards,
Guy

"Michael Nemtsev [MVP]" wrote:
Hello guy,

What you need to do is upload in to server when you click ok. Example is
there http://www.beansoftware.com/ASP.NET-...-Database.aspx

So, what is the problem?!

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
:: http://twitter.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
gI'm trying by means of a FileUpload control and and "Apply" button,
gbrwosong
gmy local folders for a picture file loading (Apply button) and
gdisplaying the
g(local) picture (jpg, gif, ..) file. I don't want the local file to
gbe saved
gon the server but displayed on my webform and if ok be stored in my
gdatabase
gtogether with other related info.
gI googled and found some example .. but not exactly what i want to
gachieve.
gAnyone can give me a hint where to start?
g>
Sep 25 '08 #3
On Sep 24, 1:15*pm, Guy <G...@discussions.microsoft.comwrote:
I'm trying by means of a FileUpload control and and "Apply" button, brwosong
my local folders for a picture file loading (Apply button) and displayingthe
(local) picture (jpg, gif, ..) file. I don't want the local file to be saved
on the server but displayed on my webform and if ok be stored in my database
together with other related info.
I googled and found some example .. but not exactly what i want to achieve.

Anyone can give me a hint where to start?
An approach is when the user clicks the Submit or Preview button, the
file gets posted to the server, you temporarily store the file in
Session. On the same page, you have an Image control and you set its
ImageUrl property to an ASHX handler page that will serve the image to
the client. In the ASHX page, you get the file out of session, send
it to the client and clear the file out of session. All this is done
within a couple of seconds so the image doesn't stick around in
session very long. Here's some sample code that does this:

// ASPX page code-behind
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (fuTest.HasFile)
{
string contentType = fuTest.PostedFile.ContentType;
if (contentType.StartsWith("image/"))
{
Session["uploadFile"] = fuTest.FileBytes;
imgPreview.Visible = true;
imgPreview.ImageUrl = "image_preview.ashx";
}
}
}

// image_preview.ashx
<%@ WebHandler Language="C#" Class="image_preview" %>

using System;
using System.Web;
using System.Web.SessionState;

public class image_preview : IHttpHandler, IRequiresSessionState {

public void ProcessRequest (HttpContext context) {
byte[] img = (byte[])context.Session["uploadFile"];
if (img != null)
{
context.Response.ContentType = "image";
context.Response.OutputStream.Write(img, 0, img.Length);
// clear session
context.Session["uploadFile"] = null;
}
}
public bool IsReusable {
get {
return false;
}
}
}
Sep 25 '08 #4
Hello guy,

But how are you going to show the image if file don't exist anywhere?! It
should be uploaded somewhere first, to temporary location I'd say and then
you need to show it.

You can use sessions or cache, but file must be on server to be shown

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
:: http://twitter.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
gThanks for the info.
g>
gI want, before storing the picture in the db, already display the
gimage on the webform and save to the db when all other info has been
gentered. If I'm right the example link you provided doesn't handle
gthis displaying of the image before storing to the db?!
g>
gRegards,
gGuy
g"Michael Nemtsev [MVP]" wrote:
g>
>Hello guy,

What you need to do is upload in to server when you click ok. Example
is there
http://www.beansoftware.com/ASP.NET-...les-To-Databas
e.aspx

So, what is the problem?!

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog:
http://spaces.live.com/laflour
:: http://twitter.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

gI'm trying by means of a FileUpload control and and "Apply"
button,
gbrwosong
gmy local folders for a picture file loading (Apply button) and
gdisplaying the
g(local) picture (jpg, gif, ..) file. I don't want the local file
to
gbe saved
gon the server but displayed on my webform and if ok be stored in
my
gdatabase
gtogether with other related info.
gI googled and found some example .. but not exactly what i want to
gachieve.
gAnyone can give me a hint where to start?
g>

Sep 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: DH | last post by:
I have a "file upload form" that works OK, but I have been unsuccessful in my attempt to also resize the uploaded .JPG (if it is too wide), over-writing the original .JPG, and then create and save...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
6
by: Neo Geshel | last post by:
About 4 months ago I came across this one web page that talked about streaming raw image data (from a database, for example) directly to a web page without requiring a secondary ASPX page to...
9
by: Mark Denardo | last post by:
This is related to another post I submitted, but I'll be more precise this time. I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUrl="<username>.jpg",...
4
by: finecur | last post by:
I am working on the project. Here is the work flow. server. The server will do some calculation based on the data in the file and return an image in Jpg format. The returned image will be...
7
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a...
1
by: jamal8t2 | last post by:
<?php //$file_dir="/htdocs/upload"; // Connect to database $db_name1="test";// Database name $conn1=mysql_connect("localhost","","") or die("I Couldn't connect"); ...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.