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


Similar Messages:

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

Data Controls :: Display Data From Database In Word Document

Oct 21, 2015

i use select query i need to show the data in word after click the button

View 1 Replies

Web Forms :: How To Display The Uploaded Image On The Webpage

Aug 22, 2010

Does anyone know how to display the uploaded image onto the webpage after the image has been uploaded via the asyncfileupload control?

I tried setting the value of an imageurl property of an image control within the OnUploadComplete event however it seems the code 1st refreshes the page, runs through the Page_Load event, then finally the OnUploadComplete, so I'm assuming since it's run last, this is why it doesn't display the imageurl.

View 1 Replies

AJAX :: Display Uploaded Image Via Javascript?

Jun 1, 2010

I have an asyncfileupload control. AFTER the file has been successfully saved to disk I want to assign the uploaded image to a HTML element. To show it to the user.

Important: in the afuFlyer_UploadedComplete method I'm renaming the image, so the image saved to disk does NOT have the same name as the file the user initially uploaded.

I have this:

<cc1:AsyncFileUpload ID="afuFlyer" OnClientUploadComplete="Async_UploadComplete" OnUploadedComplete="afuFlyer_UploadedComplete" UploaderStyle="Modern" runat="server" />

and a javascript function:

function Async_UploadComplete(sender, args) {
var filename = args.get_fileName();
var contentType = args.get_contentType();
var text = "Size of " + filename + " is " + args.get_length() + " bytes";
document.getElementById('lblStatus').innerText = text;
}

But the args.get_fileName(); is useless since the filename has been changed. So I need to pass the new filename to this method somehow?
Also, is the image actually already saved to disk when the Async_UploadComplete function is called? Or has the upload to the server just been completed and not the saving to server disk?

Ive also tried working with ScriptManager.RegisterClientScriptBlock and ScriptManager.RegisterStartupScript in afuFlyer_UploadedComplete method without success:

View 2 Replies

Web Forms :: Read The Pdf File Uploaded By User And Display Content

Mar 22, 2010

i want to read the pdf file uploaded by the user and to display the content of the pdf file in asp.net webpage...(not the pdf file itself ).

View 3 Replies

Data Controls :: How To Display Uploaded File Name In GridView Like Gmail

Aug 5, 2012

i used your application multiple file upload like gmail that is fantastic.but what i want when it's uploaded in the folder it should show in gridview with file name just like gmail.

View 1 Replies

Web Forms :: Load And Display Uploaded Image Immediately After Upload?

Feb 16, 2013

i want to load image into image  control emmidiatly when i am uploading it by using fileupload control that means when i am uploading a file i display on the page immediately on page in image control.

View 1 Replies

AJAX :: Display Photo On Employee Registration Form As Soon As It Is Uploaded

Dec 13, 2012

How to upload the photo and display in the image control,in the same employee form...the image is displayed in the right side. I've written the code for upload image,the image will uploaded successfully, I want to display on the same page.

View 1 Replies

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

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 :: 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

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

Web Forms :: Display Generic Error Page When Uploaded File Exceeds Limit

May 7, 2015

Below is the code for "Upload" button when uploading any file:

if (contenttype != String.Empty) {
if (File.Exists(Server.MapPath("~/Folder/'" + Txt.Text + "'/") + filename)) {
LMsg.Visible = true;
LMsg.ForeColor = Color.Red;
LMsg.Text = "File name '" + filename + "' already exist. Please change the File name to save this file";

[Code] ....

File upload control allows maximum file size is 4MB. If file size increase to 4MB it shows error page like "the page can not displayed".

I want to increase the size of uploaded files to max 10 MB not more than that. If file size increase to 10MB, it should show message.

View 1 Replies

Display The PDF Document In Webpage?

Mar 13, 2010

how can i add a sticky notes in my asp.net webpages.... i have a requirement where i need to display the PDF document in my webpage ... and i need to add the sticky notes to that pdf document... can any one guide me .... about how to start to achieve this....

View 5 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

How To Display Document Content On Webpage

May 12, 2010

How to display document(xls,doc,pdf) dirctely on the web page. send the related links also..

View 5 Replies

How To Read And Display Word Document

Apr 8, 2010

I have a file up-loader by which i upload the .doc file in a folder on server.]

I want to display the whole word document content on a label as it is in .doc file in C#.

View 2 Replies

SQL Server :: How To Display The Word Document

Aug 10, 2010

how to display the word document which is binary document which is stored in database?

View 2 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 :: Display MS Word Document In HTML Via ASP?

May 18, 2010

I have never used ASP before!I have a server which has a shared folder where all quotes for our small business are saved.I have setup a HTTPs website with authentication, which then allows you to browse the folder contents as HTML. If you WORD installed on your machine you can download and open. No need to be able to save or anything - it is for viewing only.

The trouble I have is that every now again you are on a site where you cannot open the document as there is no software to do so. I would like to be able to display the WORD doc in a web browser.I have googled and it seems it is possible, but I am struggling with a result.All I want to do is view the WORD document in an HTML page. It could even be just the text less the formatting and header/footer if this was easier to achieve.Running MS Server 2003 SBS, and currently still using MS Office 2000!

View 2 Replies

Display The Upload Document Content To Webpage?

May 12, 2010

Actually i want code of when user upload his document, its automatically generate all the content of document to display in the web page.. and all the code belongs to c#,javascript,jquery

View 1 Replies

Using Nested Query To Display Document List?

Apr 28, 2010

I using the two tables below to create a list of category titles containing document links so it looks like this:

documentCategoryName
documenttitle
documenttitle
documentCategoryName
documenttitle
documenttitle

Here are my tables:

documents table
documentID int Unchecked
documentName nvarchar(MAX) Checked
documentCat int Checked
documentDescription ntext Checked
documentType nvarchar(MAX) Checked
documentSiteID int Checked
Document category
documentCategoryId int Unchecked
documentCategoryName nvarchar(MAX) Checked

To do this I'm using a nested query which involves alot of code.

all my page code is below:

[Code]....

View 2 Replies

Controls :: Display Word Document On Webpage?

Dec 27, 2013

How Can i Show the resume on web page after uploading the resume .......

View 1 Replies







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