C# - How To Save Uploaded Pics In Database

Sep 27, 2010

in my new c#.net 3.5 ASP Website, user have the possibility to upload a picture.What solution is the best for saving this picture? Should I save it on my server in a folder and save the path in the database, or should I save the picture in the database?

View 3 Replies


Similar Messages:

Web Forms :: How To Save Name Of Uploaded File In Database

May 7, 2015

I have 1 fileupload control that I can upload file from it below is code :

int count = 0;
if (this.fuppdf.HasFile && !string.IsNullOrEmpty(this.txtarticle.Text))
{
string[] validext = { ".pdf" };
//string ext = System.IO.Path.GetExtension(fuppdf.PostedFile.FileName);
string ext = Path.GetExtension(fuppdf.PostedFile.FileName);

[code].....

and with below code I want save filename (uploaded filename) in database

SqlCommand _cmd = new SqlCommand("Fileuppdf", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
string data = Session["behcode"].ToString();
_cn.Open();
_cmd.Parameters.AddWithValue("@pdf", filename);
_cmd.Parameters.AddWithValue("@Behcode", data);
_cmd.Parameters.AddWithValue("@id", Convert.ToInt32(ViewState["Id"]));

but it make error in this line

_cmd.Parameters.AddWithValue("@pdf", filename);

error===>("The name 'filename' doesn't exist in the current context")

I know that I define filename in 

foreach (string s in files)but I don't know how I can save it name in database

View 1 Replies

DataSource Controls :: Save Uploaded File Path In Database

Apr 26, 2010

how can we save the uploaded file path in to database and then retrieve it in gridview as a link so when user click on that it will open that file in browser.

View 8 Replies

SQL Server :: Database With Pics Advice?

Jan 22, 2011

Am building an app in VB.NET | ASP.NET 4 | SQL 2008 R2I am building an site that will potentially have upto 15, 000 pics for now. More added each weekWould it be best to insert those pics (from a few kb to 2.5 Mb per pic) into the database or have them in a directory with links to those pics in the database?The site will have pages of pics which the user can browse or click on taking them to another page with info. Basically like a photo album

View 6 Replies

<path> Is Denied When Using The FileUpload Control To Save The Uploaded File?

Apr 21, 2010

I am running Windows Server 2008 Datacenter, ASP.NET 4, IIS 7 and getting the error :Access to the path <path> is denied when using the FileUpload control to save the uploaded file to this directory.I have given the directory in question full access to Network Service but that makes no difference.I have even given the directory full access to Everyone but it still gives the same error.Totally baffled by it

View 1 Replies

Data Controls :: How To Save Video Files Into Folder And Save Path Only Into Database

May 7, 2015

How To Save Video files into folder and save path only into database in asp.net using c#.

View 1 Replies

When Click On Save Button, Use Jquery To Save Form Entity In Database?

Jul 28, 2010

one button i use to save form entity.and other is to navigate to next pagwhen i click on save button i use jquery to save form entity in database. and form remains as it is

<script type="text/javascript">

View 2 Replies

Web Forms :: Uploaded Photo Displayed And An Hyperlink Option To Save Photo?

Jan 22, 2011

in asp.net i want the user to chose a photo to upload from their HD . then i want the uploaded photo displayed and an hyperlink option to save or reject this photo. if accepted the filename will be stored in a DB.

the problem is displaying the photo before it has been saved.

I display strFileName which works on my PC but not on my laptop.

[code]

View 4 Replies

Display Uploaded Document From Database

Oct 10, 2010

I have a MVC 2 web application. The website captures grant applications for loans. With each application I can upload documents. The way that we upload documents to the database is as follows:

private IEnumerable<byte> GetStreamByteArrayData(Stream stream)
{
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
for (int byteIndex = 0; byteIndex < bytesRead; byteIndex++)
{
yield return buffer[byteIndex];
}
}
}

The calling method looks like this:

Convert.ToBase64String(GetStreamByteArrayData(hpf.InputStream).ToArray());

In my grid that displays the uploaded documents I have the document name, mime type and so forth. What I am trying to do is to have the name of the document in a link. When the link is clicked then the document is opened. I have no idea how to do this in an MVC app. Can someone provide some sample source code?

View 2 Replies

Insert Uploaded Images Into A Database?

Feb 11, 2011

I want to insert uploaded image in root directory images folder and its path to image column in database.

I am using the following code. It inserts the path to images in the database column, but not the filename:

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
On Error Resume Next
If FileUpload1.HasFile Then
FileUpload1.SaveAs(IO.Path.Combine(Server.MapPath("images"), FileUpload1.FileName))
End If
'/// upload images
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Table3 (city, hotel, location, avialiability, room, price, image, category, from1, to1, price1, from2, to2, price2, from3, to3, price3, details) VALUES('" & Trim(DropDownList1.SelectedItem.Text) & "','" & Trim(DropDownList2.SelectedItem.Text) & "','" & Trim(TextBox5.Text) & "','" & Trim(TextBox6.Text) & "','" & Trim(DropDownList3.SelectedItem.Text) & "','" & Trim(TextBox7.Text) & "','" & "images/" & FileUpload1.FileName & "','" & Trim(TextBox17.Text) & "','" & Trim(TextBox8.Text) & "','" & Trim(TextBox9.Text) & "','" & Trim(TextBox10.Text) & "','" & Trim(TextBox11.Text) & "','" & Trim(TextBox12.Text) & "','" & Trim(TextBox13.Text) & "','" & Trim(TextBox14.Text) & "','" & Trim(TextBox15.Text) & "','" & Trim(TextBox16.Text) & "','" & (Editor1.Content) & "')"
cmd.ExecuteNonQuery()
con.Close()
End Sub

View 2 Replies

Web Forms :: Saving Uploaded Image To Database

Feb 21, 2012

I am trying to make a photo gallery. I want to save the uploaded image to data base ...the article below at "
Display image after upload without page refresh or postback using ASP.Net AsyncFileUpload Control" shows how to show the uploaded image.. How to save the image in SQl Database?

I do not know how to do it.. Can the code be modified..? 

View 1 Replies

DataSource Controls :: Remove Uploaded Document From Database?

Jan 30, 2010

I have a Document name column with varbinary(max) type column in my table

first time when i upload document i am storing doc as a byte array

Dim fs As Stream = Me.fileupload1.PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(fs.Length)

in my application i have remove atttachmentDoc button, i want to remove uploaded doc from db

so when i pass like this to my storedprocedue

Dim obj As New cls1
Dim bData() As Byte = New Byte(0) {}
bData=nothing
With obj
Dim dt As DataTable = Read_Doc()
If dt.Rows.Count > 0 Then
If Not IsDBNull(dt.Rows(0)("Document")) Then
.Document = bData
.Document_extension = ""
.Remove_Attachment(Me.Selected_ID)
End If
End If
End With

i got error

dbAccess.executeQuery: Procedure or function 'SP_DML1' expects parameter '@Document', which was not supplied.

View 1 Replies

Web Forms :: Compressing Of Pics?

Nov 26, 2010

i m using photo gallery in a website but pics takes much time to be view than any other sites like facebook or orkut. hw can i overcome this problem. i m resizing the image on file upload btn. you can check the url www.sanskarbhartipublicschool.com/photogallery

View 1 Replies

Website Inserting Pics?

Jan 17, 2011

getting this error message : Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 7:
Line 8: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Line 9: UserIdValue.Text = Membership.GetUser().ProviderUserKey.ToString()
Line 10: cannotUploadImageMessage.Visible = False
Line 11: End Sub

View 1 Replies

Web Forms :: How To Change Pics In Web Dynamically

Sep 30, 2010

i have pics in my website in differnt pages with width and height set to 320*320 px how can change this images in admin section to be replace by new one and with the same size. i m using file concept of storing the images

View 6 Replies

C# - Sync Database To Uploaded File Using Windows Service Or Website Code?

Sep 10, 2010

I have a website that occasionally needs to have a handful of the tables in its database updated. The updates come from another system that exports to comma delimited text files. I can then either FTP the text files to the web server, send them in through an admin upload page, or manually log in to Remote Desktop to download the text files. I have all my C# code written to parse the files, check the database contents, and decide what to do.

Should I code the sync logic to be part of a file upload page, protected in the admin section of the site or should I create a Windows Service that constantly looks for files to process in a particular directory that I can drop files in through FTP?

I have used Windows Services in the past and they have worked great, but if I ever have to make a change to the code it can take longer than it would if I just had to modify an ASPX.

Are their security benefits one way or another?

Performance benefits?

ASPX page wins the "ease of maintenance" category.

View 1 Replies

Forms Data Controls :: Storing Uploaded File Content Into Database?

Dec 15, 2010

I am working on the application that allows user to upload a file (from their local machine) and store the uploaded file in database.Then,the content of the file (such as ContentType,FileSize etc)can be view in a DetailsView control.

View 1 Replies

Web Forms :: Way To Upload Pics To User Profile

Nov 5, 2010

i,m workign on mailing project , and in a user table i added the UserImage feild in the user table and i uploaded the images to the database as bytes but it make the size of the database too large so i wanna upload images for users to a folders but link them to database table to use them when i make queries to retrive user image or user data like (Request.Querystring["ID"])

View 4 Replies

DataSource Controls :: Storing An Attachment Uploaded By User In RadGrid Into Sql Server 2005 Database

Jun 9, 2010

I am a new-bie in Asp.Net.I am working in a project where I need to store an attachment which will be uploaded by the user in radGrid into Sql server 2005 database.After storing this attachment, I have to retrieve this attcahment and show the same to the other users in radGrid so that they will be able to download the attachment and see that.How should I do that?what kind of datatype would it be?

View 2 Replies

How To Make Pictures Change, On A Page, I.e. Show 5 Pics, One After Another, After A Few Seconds

Nov 30, 2010

Am building a site for someone

www.wecount.ie

and he wants the photo on the front page to change, to another photo, every few seconds, say 3 seconds, so he can show several pics on one page.

View 6 Replies

Web Forms :: Creating A Thumbnail.aspx Page That Shrinks Pics Offsite?

May 24, 2010

working on a client's website that has a gallery and uses a thumbnail.aspx page to shrink images on their site for product galleries. However, they want to move the image files to another URL so I need to modify the thumbnail.aspx code to use a networkstream, but I'm not sure exactly how to do this. Could someone point me in the right direction?

View 2 Replies

Web Forms :: Save File In Folder On Disk Vs Save File In Database

Jan 4, 2014

What is the best way to insert and retrieve images like :

In the database in binary form retrieve it with imagehandler, or

In the database by saving the path of the folder of the images and retrieve it, or

by saving the images directly to the folder and retrieve it...

View 1 Replies

Web Forms :: Have A Few Websites That Should Access A Central Location (folder) On A Different Domain That Stores Pics?/

Oct 21, 2010

I have a few websites that should access a central location (folder) on a different domain that stores pics. In previous version of this system I stored each pics folder under the same domain and I could access the files with FileInfo

Dim fi As FileInfo = New FileInfo(MapPath(img.ImageUrl))
How can I ger the file info for a file in a different domain ?

View 9 Replies

Trying To Save Changes To A SQL Database, Results In "Cannot Open User Default Database. Login Failed."

Feb 3, 2010

I am building an MVC application with C# as my language which is hosted on Widows 7 IIS. A call to Add a new member to the database works, but when attempting to save the change I get the following error:

Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOLmyApplication'

The SQL table was added just by adding it within VS.

View 1 Replies

How To Save Pictures In A Database

Mar 3, 2011

How do you save pictures in a database? Do you just store the path of the stored image or can you actually put an image in a database?

Using: VB.net code; Asp.net; Visual Web Developer 2008; Access and SQL Databases

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved