Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > uploading pictures

Reply
Thread Tools

uploading pictures

 
 
Jeff
Guest
Posts: n/a
 
      03-25-2009
hi

asp.net 2.0

I'm creating a webpage where admin can write articles and upload pictures
associated with that article. There can be n pictures. So the pictures need
to be stored in a separated table with foreign key to the article table

So I thought I about put an FileUpload control on the page, together with an
upload button. When clicking on the upload button the picture is "uploaded"
but not yet stored on the server. In addition I want a Repeater control on
the page to display a thumbnail of the picture after it's been "uploaded",
so that admin can see which pictures are uploaded and discard a picture if
he feels like doing that...

When admin save the article, the uploaded pictures are stored in the
database...

I'm unsure how to do this. More specifically I'm unsure how to store
pictures in the database. I mean the page has just some thumbnails to the
pictures... not sure how to save the fullsize to the database... maybe I
need to hold an array of streams, streams to each picture...

any suggestions?


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      03-25-2009
On Mar 25, 2:11*pm, "Jeff" <(E-Mail Removed)> wrote:
> hi
>
> asp.net 2.0
>
> I'm creating a webpage where admin can write articles and upload pictures
> associated with that article. There can be n pictures. So the pictures need
> to be stored in a separated table with foreign key to the article table
>
> So I thought I about put an FileUpload control on the page, together with an
> upload button. When clicking on the upload button the picture is "uploaded"
> but not yet stored on the server. In addition I want a Repeater control on
> the page to display a thumbnail of the picture after it's been "uploaded",
> so that admin can see which pictures are uploaded and discard a picture if
> he feels like doing that...
>
> When admin save the article, the uploaded pictures are stored in the
> database...
>
> I'm unsure how to do this. More specifically I'm unsure how to store
> pictures in the database. I mean the page has just some thumbnails to the
> pictures... not sure how to save the fullsize to the database... maybe I
> need to hold an array of streams, streams to each picture...
>
> any suggestions?


Check this first
http://www.google.com/search?q=asp.n...n+the+database
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      03-25-2009
thanks for the link

I think I create a custom class which holds these values from the FileUpload
control:
FileUpload .FileName,
FileUpload .PostedFile.ContentLength,
FileUpload .FileBytes,
FileUpload .PostedFile.ContentType

Then declare an generic list, for example List<Picture> picture which for
each time I upload a picture I add that picture to this generic list. and
then I can also use this generic list as datasource for the repeater
control... when admin saves the article, I send this generic list as an
input parameter into that article and then saves those pictures belonging to
that article...

Unsure if the generic list holds the data between postbacks and stuff like
that.. so I'll give it a try and see what I discover...

any suggestions are most welcome


 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      03-25-2009
as I was fearing, the generic list didn't hold it's values between
postbacks... Here is my code:

public partial class _Default : System.Web.UI.Page
{

List<Picture> pictures = new List<Picture>();

protected void Page_Load(object sender, EventArgs e)
{

}


protected void lbUpload_Command(object sender, CommandEventArgs e)
{
if (FileUpload1.HasFile)
{
Picture picture = new Picture(FileUpload1.FileName,
FileUpload1.PostedFile.ContentLength,
FileUpload1.FileBytes,
FileUpload1.PostedFile.ContentType);
pictures.Add(picture);
}
}


}

any suggestions/comments are most welcome


 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      03-25-2009
I'm looking up viewstate in the documentation now....


 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      03-25-2009
I think storing an generic list of pictures in viewstate is too much, think
it will make the page terrible slow

now looking for alternatives....


"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm looking up viewstate in the documentation now....
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      03-26-2009
On Mar 25, 9:41*pm, "Jeff" <(E-Mail Removed)> wrote:
> thanks for the link
>
> I think I create a custom class which holds these values from the FileUpload
> control:
> FileUpload .FileName,
> FileUpload .PostedFile.ContentLength,
> FileUpload .FileBytes,
> FileUpload .PostedFile.ContentType
>
> Then declare an generic list, for example List<Picture> picture which for
> each time I upload a picture I add that picture to this generic list. and
> then I can also use this generic list as datasource for the repeater
> control... when admin saves the article, I send this generic list as an
> input parameter into that article and then saves those pictures belonging to
> that article...
>
> Unsure if the generic list holds the data between postbacks and stuff like
> that.. so I'll give it a try and see what I discover...
>
> any suggestions are most welcome


If I were you I would use a database for this. You already uploaded a
files to the database. Say, you have a table

ArticleID
FileName
ContentLength
FileBytes
ContentType
ImageData

where ArticleID is an id of the article images belong to. Use that
table as a datasource for the repeater control

SELECT FileName, ... FROM Table1 WHERE ArticleID=1234

If article was not uploaded yet, you can create a record in the
database for this (to get an ArticleID) once the first image was
attached. In this case you maybe would need to have a status field to
identify Active/Non-active articles

ArticleID
ArticleName
ArticleText
Status
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading pictures beethovenofear HTML 4 04-23-2006 11:50 AM
Need help uploading pictures... henree21@yahoo.com Digital Photography 1 03-07-2006 08:42 PM
ftp uploading vs. control panel uploading Dung Ping HTML 10 01-16-2006 10:43 AM
Card readers freeze computer when uploading pictures through usb 2.0 hasenhaxe Digital Photography 1 07-27-2005 12:38 AM
Uploading pictures to computers without installing drivers or other software GM Digital Photography 10 10-16-2003 03:52 AM



Advertisments