Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Reading a file in local drive using Java script

Reading a file in local drive using Java script

Scheduled Pinned Locked Moved JavaScript
javajavascripthtmlsysadmintools
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shir_k
    wrote on last edited by
    #1

    Hi, Need to create a program using Javascript to read the binary file located in the PC(C or D drive) and copy the file contents to a variable in Java Script and send the file data to server. Can this be done without using Active X contols? Am using 'file' input type in HTML 1.0 for getting the path of the file.

    G 1 Reply Last reply
    0
    • S shir_k

      Hi, Need to create a program using Javascript to read the binary file located in the PC(C or D drive) and copy the file contents to a variable in Java Script and send the file data to server. Can this be done without using Active X contols? Am using 'file' input type in HTML 1.0 for getting the path of the file.

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      No, you cannot do that just using Javascript from a browser.

      S M 2 Replies Last reply
      0
      • G Graham Breach

        No, you cannot do that just using Javascript from a browser.

        S Offline
        S Offline
        shir_k
        wrote on last edited by
        #3

        Hi, Is there any other method to read without using Active X control? Thanks

        G 1 Reply Last reply
        0
        • S shir_k

          Hi, Is there any other method to read without using Active X control? Thanks

          G Offline
          G Offline
          Graham Breach
          wrote on last edited by
          #4

          If all you want to do is get the file from the client to the server, the file input type will do it without any Javascript or ActiveX required. If you want a bit more control over how it works, you could try something like SWFUpload[^] which uses a Flash movie to give you a progress bar, etc.

          S 1 Reply Last reply
          0
          • G Graham Breach

            If all you want to do is get the file from the client to the server, the file input type will do it without any Javascript or ActiveX required. If you want a bit more control over how it works, you could try something like SWFUpload[^] which uses a Flash movie to give you a progress bar, etc.

            S Offline
            S Offline
            shir_k
            wrote on last edited by
            #5

            Hi, Using file input type we can only browse the file, my requirement is 1)Browse the binary file 2)Read the contents of the file 3)store the file contents 4)send the stored file contents to server.

            G 1 Reply Last reply
            0
            • S shir_k

              Hi, Using file input type we can only browse the file, my requirement is 1)Browse the binary file 2)Read the contents of the file 3)store the file contents 4)send the stored file contents to server.

              G Offline
              G Offline
              Graham Breach
              wrote on last edited by
              #6

              Using <input type="file">, the contents of the file is loaded by the browser and sent to the server when you submit the form. If you want to send the file without submitting the form, you will have to use Flash, or ActiveX, or something similar.

              S 2 Replies Last reply
              0
              • G Graham Breach

                Using <input type="file">, the contents of the file is loaded by the browser and sent to the server when you submit the form. If you want to send the file without submitting the form, you will have to use Flash, or ActiveX, or something similar.

                S Offline
                S Offline
                shir_k
                wrote on last edited by
                #7

                I was thinking it will only help to browse the path. Will try. Thanks

                1 Reply Last reply
                0
                • G Graham Breach

                  Using <input type="file">, the contents of the file is loaded by the browser and sent to the server when you submit the form. If you want to send the file without submitting the form, you will have to use Flash, or ActiveX, or something similar.

                  S Offline
                  S Offline
                  shir_k
                  wrote on last edited by
                  #8

                  Server side code is in CSP. Upon using submit button, HttpMethod_Post is called. In HttpMethod_Post function fopen will not work as path is in local PC and server is in the device How to copy the data or send the data to server in the device?? Can you please provide code or link.

                  G 1 Reply Last reply
                  0
                  • S shir_k

                    Server side code is in CSP. Upon using submit button, HttpMethod_Post is called. In HttpMethod_Post function fopen will not work as path is in local PC and server is in the device How to copy the data or send the data to server in the device?? Can you please provide code or link.

                    G Offline
                    G Offline
                    Graham Breach
                    wrote on last edited by
                    #9

                    Sorry, I don't know anything about CSP - a quick Google found me this though: http://barracudaserver.com/ba/doc/en/C/reference/html/structHttpUpload.html[^]

                    S 1 Reply Last reply
                    0
                    • G Graham Breach

                      No, you cannot do that just using Javascript from a browser.

                      M Offline
                      M Offline
                      Matt Meyer
                      wrote on last edited by
                      #10

                      Graham Breach wrote:

                      No, you cannot do that just using Javascript from a browser.

                      Actually... You used to not be able to do it with a browser (was viewed as a security hole). However, with HTML5, browsers have started putting in functionality to trap the filestream when a user selects a file in the input box. More details are here: http://www.html5rocks.com/en/tutorials/file/dndfiles/[^] Personally, I still view it as a security problem because I remember all of the details from back in the day, but my opinions don't seem to be falling in line with the new generation of web folks. (yea, yea, get off my lawn and all that) :)

                      G 1 Reply Last reply
                      0
                      • M Matt Meyer

                        Graham Breach wrote:

                        No, you cannot do that just using Javascript from a browser.

                        Actually... You used to not be able to do it with a browser (was viewed as a security hole). However, with HTML5, browsers have started putting in functionality to trap the filestream when a user selects a file in the input box. More details are here: http://www.html5rocks.com/en/tutorials/file/dndfiles/[^] Personally, I still view it as a security problem because I remember all of the details from back in the day, but my opinions don't seem to be falling in line with the new generation of web folks. (yea, yea, get off my lawn and all that) :)

                        G Offline
                        G Offline
                        Graham Breach
                        wrote on last edited by
                        #11

                        Interesting stuff - thanks for the link. I always thought the file upload support was a bit too limited to be honest. As long as the user still has to choose which files the browser can access this looks like a big improvement.

                        M 1 Reply Last reply
                        0
                        • G Graham Breach

                          Interesting stuff - thanks for the link. I always thought the file upload support was a bit too limited to be honest. As long as the user still has to choose which files the browser can access this looks like a big improvement.

                          M Offline
                          M Offline
                          Matt Meyer
                          wrote on last edited by
                          #12

                          I do welcome the drag and drop features (this is probably the most common request I used to have when doing web stuff). However, I don't like the idea of implicitly agreeing to local file access by just selecting something in a file input field. Especially since Firefox forces you into the file dialog when you focus on the field, and you cannot delete the input field's contents after selecting a file.

                          1 Reply Last reply
                          0
                          • G Graham Breach

                            Sorry, I don't know anything about CSP - a quick Google found me this though: http://barracudaserver.com/ba/doc/en/C/reference/html/structHttpUpload.html[^]

                            S Offline
                            S Offline
                            shir_k
                            wrote on last edited by
                            #13

                            Hi, How to get data when When we use on the webpage we get the option to select the file to be read. Upon submitting we get the data right but how to copy the recieved data or send to server?? The control goes to below code upon submitting. if(request->getMethodType() == HttpMethod_Post) { }

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups