Re: File IO

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I see two separate aspects here. getting the file from the server to the
client and then getting it back from the client to the server.

First - getting the file to the client...

As I understand it you have an aspx page that pulls a byte array from a
binary column in your db and you want to stream that out to the browser so
the browser will automatically open the appropriate application depending
upon the content type (known as MIME type - Google MIME for more info
including many "standard" types)?

You need to set the HTTP header in the response to tell the browser what
MIME type is coming. The browser looks up in the local machine to see what
program to use. For example if the HTTP content type header says
"application/word" then it will try to open Word and pass it the content.

If you specifically want the content to be downloaded and not opened
(forcing the Save As... dialog box to appear) you need to set the content
disposition to "attachment"

Here's a few lines from an aspx page I use for a similar (I think)
purpose...

If (forceDownload) Then
Response.AppendHeader("Content-Disposition",
"attachment; filename=" + fileName)
Else
Response.AppendHeader("Content-Disposition", "filename="
+ fileName)
End If
Response.ContentType = contentType
Response.OutputStream.Write(fileData, 0, fileData.Length)

Second - getting the file from the client to the server...

Some applications are able to save a file directly to a web URL. Excel and
other MS Office applications have been able to do this for many years, but
it relies upon the server being set up to accept files being written by an
HTTP request. Most web masters go to great lengths to prevent this kind of
operation.

It's likely that you will need to have your users edit and save locally and
then upload their finished work via a web page. I suspect you already have
the code for this worked out; receive the file as a HTTP POST file upload,
convert it to a byte array, save it to your binary column in your db.

If I'm comepletely off track just ignore me.

Brian Lowe
---------@


"Ragu" <Ragu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3873F58-702E-4504-A853-02456269FE4C@xxxxxxxxxxxxxxxx
Hi Rae

Thanx for your reply.

As the file is stored as a byte array in the database, it is not possible
to
give the absolute url of the file to the window.open method.



"Mark Rae" wrote:

"Ragu" <Ragu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DC8FBC7A-5324-43FB-9EED-D1DA0393C6B5@xxxxxxxxxxxxxxxx

Hello Rae

:-)

I have 2 buttons near the grid.

One is edit button and anothet is a preview button.

when i check a row in the grid and click the preview button, i need to
open
the file and show with word/excel/paint or any relevant application.

Well, that should be easy enough with client-side JavaScript using the
window.open() method and passing the absolute URL of the document...
http://www.google.co.uk/search?sourceid=navclient&aq=t&ie=UTF-8&rls=GGLG,GGLG:2006-28,GGLG:en&q=JavaScript+%22window%2eopen%22

when i check a row in the grid and click the edit button, the files
againg
open like that of the preview button and the edit button text is
changed
to
save, and after making the changes in the file, if i click the save
button,
the location of the file has to be identified and convert the file to
byte
array and save it to the database.

OK, so you want to open e.g. an Excel spreadsheet which resides on a
webserver, allow the user to edit the file client-side, and then save the
modified file in the form of a byte array into a database...?

Hmm - I think that's going to be a little tricky and quite messy... Other
than using something like SharePoint, I can't think of any other way
apart
from downloading the file to the local machine, editing it locally,
saving
it locally, then uploading the saved version back to the webserver with
an
HtmlInputFile control...





.



Relevant Pages

  • TCP/IP Client/Server noob question
    ... i'm a little confused how to actually send the server data, ... Client sends data. ... Client creates a byte array the size of one class object, ... Server then receives the next number of bytes for one object, decodes ...
    (microsoft.public.dotnet.csharp.general)
  • TCP/IP Client/Server question
    ... i'm a little confused how to actually send the server data, ... Client sends data. ... Client creates a byte array the size of one class object, ... Server then receives the next number of bytes for one object, decodes ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: passing a NULL pointer from vb6 to an ATL method
    ... Is all this necessary if the client and server are in the same apartment? ... Dim array as Double ...
    (microsoft.public.vc.atl)
  • Re: FILE* behaviour over BSD sockets - how?
    ... I made a server side program that executes fscanf, ... The client side prints an array from the other side of the connection, ... I thought that perhaps it's something about signals. ...
    (comp.unix.programmer)
  • Re: How to update entries in a file
    ... For those of us who write books, not everything is covered in them and hence ... The below is done using sockets and I have the server and the client working ... Why isn't line 1 passed into the array? ...
    (comp.lang.perl.misc)