Uploading a file without, as it were, actually uploading the file-VBForums
Results 1 to 7 of 7

Thread: Uploading a file without, as it were, actually uploading the file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Uploading a file without, as it were, actually uploading the file

    On a web page, I need to allow users to input the path to a file (on shares on servers) - which will be stored in a database so I can subsequently display 'a list of documents that apply to this project'.

    If I put an input type="file" on the page, it makes it easy for the user to browse to the document ... but, when the form is submitted, the document will be uploaded to the server. I don't want the document, I just want the path.

    How would you provide the functionality to allow a user to browse to a file so that you could record the path to the file without actually uploading the file itself?

    I just want to end up showing, on a web page, a list of files like:

    \\myserver\folder20\somefolder\somefile.doc

    \\myserver2\folder50\somefolder\somefile2.doc

    I need to give users an easy way to locate those files in the first place - without having to laboriously open Windows Explorer, find the file, and copy and paste the path. A file upload control gives you access to the path - which is what I need - but I don't want the file uploaded

    If I do end up using a file upload control - I don't want to save the file on server - how can I dispose of it so I don't end up with hundreds of temp files?

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: Uploading a file without, as it were, actually uploading the file

    Yes. You can use the fileupload control. When using the File upload controls the file is save when you call the FileUpload.SaveAs method. Otherwise it is not saved.

    And for the getting the FileName you simple use FileUpload1.FileName
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Uploading a file without, as it were, actually uploading the file

    Quote Originally Posted by danasegarane View Post
    Yes. You can use the fileupload control. When using the File upload controls the file is save when you call the FileUpload.SaveAs method. Otherwise it is not saved.

    And for the getting the FileName you simple use FileUpload1.FileName
    But, does the uploaded file hang around in a temp folder somewhere?

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,011

    Re: Uploading a file without, as it were, actually uploading the file

    Just get the filename before the upload begins. I don't believe you get an upload until you call FileUpload.SaveAs method.
    Anyhow if you want the user to have a list to files on your server that he "fakely" uploads then you have to have them on the server,right? What good is showing the path of a non existent file?
    What exactly are you trying? You may be better of with another solution.
    Slow as hell.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Uploading a file without, as it were, actually uploading the file

    Quote Originally Posted by sapator View Post
    Just get the filename before the upload begins. I don't believe you get an upload until you call FileUpload.SaveAs method.
    Anyhow if you want the user to have a list to files on your server that he "fakely" uploads then you have to have them on the server,right? What good is showing the path of a non existent file?
    What exactly are you trying? You may be better of with another solution.
    As I understand it the file is uploaded when the form is submitted - in the body of the http request.

    When you call the SaveAs method the file is on the server already - SaveAs writes it wherever you tell it to write it.

    This is not the path to a non-existent file. It is the path to an existing file.

    What I need to achieve is ... Fred is running a Project. He wants everyone in the team to be able to see the list of documents associated with the project. He knows where all the files are ... he wants a page where he can point to the files and store the paths - so that a web page can then display that list of files/paths - so people can click on links to open Windows Explorer to open the files.

    I've just realised I can put the input type=file inside an Update Panel, get at the file path after a user has selected a file using javascript, write the file name to a hidden field and retrieve it when I update. So, problem solved.

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: Uploading a file without, as it were, actually uploading the file

    If you know the file list, then you can list the files in a dropdown/List then can give the option to choose file name. Does that makes sense?
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Uploading a file without, as it were, actually uploading the file

    Quote Originally Posted by danasegarane View Post
    If you know the file list, then you can list the files in a dropdown/List then can give the option to choose file name. Does that makes sense?
    Sorry, I'm obviously not making myself clear.

    My question is about letting users upload a list of files. Not upload a number of files - the files already exist on our servers. They just need to specify the location of files so that the path can be recorded in database and subsequently displayed to other users.

    If I shouted across the room to you 'hey, where are the files for the Office Move project' you might say: the quotes for moving the office furniture are in \\ourserver\officemove\removals and the quotes for installing the new network are in \\ourserver\officemove\itissues\hardware\network etc.

    You might want to upload a list of those files so that they could be displayed on an intranet so that your colleagues would have a page with links on so they could see for themselves where all the files are. That is what I am trying to do - give a user an easy way to upload where the files are - the file paths - not the files themselves.

    If I use a file input=type to give the user an easy way to locate the files (so we can record the path), when the form submits the file will be uploaded - and I don't need the file. It already exists on our servers.

    In the meantime, I have solved it. I am using javascript to save the value of the input type=file into a hidden field and have put the input type=file inside an upload panel. Which means, when the form submits, I can retrieve the path from the hidden field but, because the input type=file is inside an update panel the file does not get uploaded to the server.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.