upload a file without user having to browse or enter file name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • walterbyrd

    upload a file without user having to browse or enter file name

    I am trying to develop an app where: the same file, in the same place,
    will be uploaded, and then processed.

    Everything I can find about uploading a file, uses a form that requires
    the user to either manually enter the path and file name, or to browse
    for the file. I do not want that. Ideally, I want the user to click on
    a link, and the server side php app does the rest. Again, the file
    always has the same name, and is in the same place.

    Can I load the data into the $_File array via the code? i.e.: $_File
    [name] = "mydatafile.txt " ?

    If there is no reasonable way around the form, can I, at least, get
    have a default field appear, so that all the user has to do is verify
    the file name and press the submit button?

  • Alvaro G. Vicario

    #2
    Re: upload a file without user having to browse or enter file name

    *** walterbyrd escribió/wrote (26 Jul 2006 08:59:59 -0700):
    If there is no reasonable way around the form, can I, at least, get
    have a default field appear, so that all the user has to do is verify
    the file name and press the submit button?
    You can use <input type="file" value="path/to/file"but it won't work in
    Internet Explorer, Mozilla Firefox or Opera.

    JavaScript allows certain advanced file operations when using it from your
    hard disk. See these pages:


    a non-linear personal web notebook


    Maybe you can produce a form the user can save in his hard disk.

    As about PHP, it obviously has no way to reach the client computer.



    --
    -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    ++ Mi sitio sobre programación web: http://bits.demogracia.com
    +- Mi web de humor con rayos UVA: http://www.demogracia.com
    --

    Comment

    • walterbyrd

      #3
      Re: upload a file without user having to browse or enter file name

      >
      As about PHP, it obviously has no way to reach the client computer.
      >
      Why not? If the use can specify a file to upload, then why not just put
      that in the code?

      Comment

      • fsidler@n.o.s.p.a.m.gmail.com

        #4
        Re: upload a file without user having to browse or enter file name


        walterbyrd wrote:

        As about PHP, it obviously has no way to reach the client computer.
        >
        Why not? If the use can specify a file to upload, then why not just put
        that in the code?
        Why? Because PHP is executed on the server, and sent to you as plain
        text after completion.
        To HTTP send a file using a form, that form still has to be submitted.
        JS might help, check the links above.

        Comment

        • PTM

          #5
          Re: upload a file without user having to browse or enter file name

          "walterbyrd " <walterbyrd@ina me.comwrote in message
          news:1153935636 .883656.83670@7 5g2000cwc.googl egroups.com...

          >As about PHP, it obviously has no way to reach the client computer.
          >>
          >
          Why not? If the use can specify a file to upload, then why not just put
          that in the code?
          >
          php is server side. once your page is loaded it cant actually do anything
          with it unless a link or button requests another php function or script

          you could always use a hidden field containing the information you would
          expect for the file to be submitted.
          then have a submit button that would process the form and do the upload.
          you would also need to verify that the file was actually located and called
          what you expected, users being what they are this might not always be the
          case

          Phil


          Comment

          • walterbyrd

            #6
            Re: upload a file without user having to browse or enter file name


            PTM wrote:
            php is server side. once your page is loaded it cant actually do anything
            with it unless a link or button requests another php function or script
            >
            As mentioned in my original post: "I want the user to click on
            a link, and the server side php app does the rest." Instead of the
            user entering the path and file name, I want the path and file name as
            part of the code.
            you could always use a hidden field containing the information you would
            expect for the file to be submitted.
            then have a submit button that would process the form and do the upload.
            you would also need to verify that the file was actually located and called
            what you expected, users being what they are this might not always be the
            case
            Something like that might work. I wish I could have the default path
            and file name in the box, like you can do when input="text" maybe I'll
            just put the default path/file name above the box, where it can easily
            cut and pasted.

            Comment

            • PTM

              #7
              Re: upload a file without user having to browse or enter file name

              "walterbyrd " <walterbyrd@ina me.comwrote in message
              news:1153955176 .597956.191740@ 75g2000cwc.goog legroups.com...
              >
              PTM wrote:
              >
              >php is server side. once your page is loaded it cant actually do anything
              >with it unless a link or button requests another php function or script
              >>
              >
              As mentioned in my original post: "I want the user to click on
              a link, and the server side php app does the rest." Instead of the
              user entering the path and file name, I want the path and file name as
              part of the code.
              >
              >you could always use a hidden field containing the information you would
              >expect for the file to be submitted.
              >then have a submit button that would process the form and do the upload.
              >you would also need to verify that the file was actually located and
              >called
              >what you expected, users being what they are this might not always be the
              >case
              >
              Something like that might work. I wish I could have the default path
              and file name in the box, like you can do when input="text" maybe I'll
              just put the default path/file name above the box, where it can easily
              cut and pasted.
              >
              if its always going to be the same and you don't need the user to browse to
              the file, then a standard input box might work ok.
              but if you do need the browse, you could try using a javascript to set the
              contents of the box when the page loads


              Comment

              • Kimmo Laine

                #8
                Re: upload a file without user having to browse or enter file name

                "PTM" <p.milbanke@vod afone.netwrote in message
                news:bFSxg.2792 5$u%3.4203@news fe1-gui.ntli.net...
                "walterbyrd " <walterbyrd@ina me.comwrote in message
                news:1153955176 .597956.191740@ 75g2000cwc.goog legroups.com...
                >>
                >PTM wrote:
                >>
                >>php is server side. once your page is loaded it cant actually do
                >>anything
                >>with it unless a link or button requests another php function or script
                >>>
                >>
                >As mentioned in my original post: "I want the user to click on
                >a link, and the server side php app does the rest." Instead of the
                >user entering the path and file name, I want the path and file name as
                >part of the code.
                >>
                >>you could always use a hidden field containing the information you would
                >>expect for the file to be submitted.
                >>then have a submit button that would process the form and do the upload.
                >>you would also need to verify that the file was actually located and
                >>called
                >>what you expected, users being what they are this might not always be
                >>the
                >>case
                >>
                >Something like that might work. I wish I could have the default path
                >and file name in the box, like you can do when input="text" maybe I'll
                >just put the default path/file name above the box, where it can easily
                >cut and pasted.
                >>
                >
                if its always going to be the same and you don't need the user to browse
                to the file, then a standard input box might work ok.
                but if you do need the browse, you could try using a javascript to set the
                contents of the box when the page loads

                Allthough the html 4.01 specification* suggests that a default filename
                could be used in a file type input field, it's prevented in the most common
                browsers simply because of user security. You just don't want a situation
                where a malicious webpage has filefields pointing to your important files
                and it's autosubmitted using javascript. To prevent malicious practise like
                this, file fields may not have an initial value.

                Of course "phishing" like this would require the malicious page to correctly
                guess the locations of sensitive files, but I'm sure that if it was
                possible, it wouldn't take long for someone to think of a way of exploiting
                it. It's for your own safety that you cannot do this.

                *) http://www.w3.org/TR/REC-html40/inte....html#h-17.4.1
                FILE
                Creates a file select control. User agents may use the value of the value
                attribute as the initial file name.

                --
                "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
                http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
                spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


                Comment

                • Peter Fox

                  #9
                  Re: upload a file without user having to browse or enter file name

                  Following on from walterbyrd's message. . .
                  >I am trying to develop an app where: the same file, in the same place,
                  >will be uploaded, and then processed.
                  >
                  >Everything I can find about uploading a file, uses a form that requires
                  >the user to either manually enter the path and file name, or to browse
                  >for the file. I do not want that. Ideally, I want the user to click on
                  >a link, and the server side php app does the rest. Again, the file
                  >always has the same name, and is in the same place.
                  There is no automatic way using PHP and normal browsers.

                  Why not use one of the zillions of backup/file synchroniser programs to
                  do the upload?

                  Or why not maintain the file at the server end without it being saved on
                  the user's computer?



                  --
                  PETER FOX Not the same since the statuette business went bust
                  peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
                  2 Tees Close, Witham, Essex.
                  Gravity beer in Essex <http://www.eminent.dem on.co.uk>

                  Comment

                  • walterbyrd

                    #10
                    Re: upload a file without user having to browse or enter file name


                    Peter Fox wrote:
                    Or why not maintain the file at the server end without it being saved on
                    the user's computer?
                    >
                    It might help to know what I am trying to do.

                    A very small warehouse just got a portable scanner. On recieving data,
                    the data is scanned in, then the data from the scanner is transfered to
                    a desktop PC. After the data is transfered to the PC, the user needs to
                    update the online database with that data. The database is kept online
                    because the clients need to view the inventory.

                    The process needs to be simplified as much as possible because the
                    warehouse workers are not that sophisticated with technology.

                    I don't think the online system can directly access the portable
                    device. Even if the device is connected, and ActiveSync is running. So
                    there must be a temporary stage, where a file is kept on the desktop
                    PC.

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: upload a file without user having to browse or enter file name

                      walterbyrd wrote:
                      Peter Fox wrote:
                      >
                      >
                      >>Or why not maintain the file at the server end without it being saved on
                      >>the user's computer?
                      >>
                      >
                      >
                      It might help to know what I am trying to do.
                      >
                      A very small warehouse just got a portable scanner. On recieving data,
                      the data is scanned in, then the data from the scanner is transfered to
                      a desktop PC. After the data is transfered to the PC, the user needs to
                      update the online database with that data. The database is kept online
                      because the clients need to view the inventory.
                      >
                      The process needs to be simplified as much as possible because the
                      warehouse workers are not that sophisticated with technology.
                      >
                      I don't think the online system can directly access the portable
                      device. Even if the device is connected, and ActiveSync is running. So
                      there must be a temporary stage, where a file is kept on the desktop
                      PC.
                      >
                      Quite simple,actually .

                      Most scanners use standard serial or keyboard interface. Simply read
                      the data in from the scanner and update the database directly. C/C++
                      would be good languages for this. Depending on the data and how you
                      need to handle it, shouldn't be more than a few hundred LOC.

                      Why do the intermediate step and complicate matters?

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Peter Fox

                        #12
                        Re: upload a file without user having to browse or enter file name

                        Following on from walterbyrd's message. . .
                        >
                        >Peter Fox wrote:
                        >
                        >Or why not maintain the file at the server end without it being saved on
                        >the user's computer?
                        >>
                        >
                        >It might help to know what I am trying to do.
                        >
                        >A very small warehouse just got a portable scanner. On recieving data,
                        >the data is scanned in, then the data from the scanner is transfered to
                        >a desktop PC. After the data is transfered to the PC, the user needs to
                        >update the online database with that data. The database is kept online
                        >because the clients need to view the inventory.
                        >
                        >The process needs to be simplified as much as possible because the
                        >warehouse workers are not that sophisticated with technology.
                        Tell me about it! Many years ago I was asked to set up a simple stores
                        system. Couldn't because none of the warehouse staff could (or could be
                        bothered to) read.
                        >
                        >I don't think the online system can directly access the portable
                        >device. Even if the device is connected, and ActiveSync is running. So
                        >there must be a temporary stage, where a file is kept on the desktop
                        >PC.
                        * So you've solved it. Your synch program starts at boot up. Scanner
                        dumps data to some file via it's comms utility. File gets beamed to
                        server. (Obviously there are a few WCPGWs you need to trap.)

                        * You could write a tiny Java program to connect to the web server then
                        use HTTP protocol to do a PUT See RFC 2616.

                        * Ask the scanner supplier for suggestions.

                        --
                        PETER FOX Not the same since the statuette business went bust
                        peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
                        2 Tees Close, Witham, Essex.
                        Gravity beer in Essex <http://www.eminent.dem on.co.uk>

                        Comment

                        • Alvaro G. Vicario

                          #13
                          Re: upload a file without user having to browse or enter file name

                          *** walterbyrd escribió/wrote (27 Jul 2006 05:42:06 -0700):
                          A very small warehouse just got a portable scanner. On recieving data,
                          the data is scanned in, then the data from the scanner is transfered to
                          a desktop PC. After the data is transfered to the PC, the user needs to
                          update the online database with that data. The database is kept online
                          because the clients need to view the inventory.
                          I'd use rsync for such purpose.

                          1) Install rsync server wherever you have your online database (if it's a
                          Linux server, it'll be already installed).

                          2) Create a module pointing to a temporary directory.

                          3) Install rsync (client) in the desktop PC.

                          4) Write a batch file to upload new images.

                          5) Create a Windows scheduled task to make the batch file execute.

                          As about security, rsync offers several alternatives, ranging from
                          passwords to user certs.

                          --
                          -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
                          ++ Mi sitio sobre programación web: http://bits.demogracia.com
                          +- Mi web de humor con rayos UVA: http://www.demogracia.com
                          --

                          Comment

                          • walterbyrd

                            #14
                            Re: upload a file without user having to browse or enter file name


                            Jerry Stuckle wrote:
                            Quite simple,actually .
                            >
                            Most scanners use standard serial or keyboard interface. Simply read
                            No, it doesn't work like that. The portable scanner is a PDA that has
                            been rigged with a laser scanner. Specifically, it's a "Symbol PPT
                            2800." The scanner/pda runs windows mobile. I think it connects to a
                            USB port. The data in the scanner is transfered with a msft application
                            called "ActiveSync " it is supposed to be the msft equivilent of Palm's
                            "HotSync."

                            There are a lot of advantages to using a portable scanner. It is not
                            tethered, you can use it anywhere without lugging a computer around.

                            Comment

                            • walterbyrd

                              #15
                              Re: upload a file without user having to browse or enter file name


                              Alvaro G. Vicario wrote:
                              1) Install rsync server wherever you have your online database (if it's a
                              Linux server, it'll be already installed).
                              >
                              I'm not so sure about that. The server uses Linux, but this is a
                              low-cost commercial service. I do not have full access to Linux. I have
                              PHP, MySQL, and Python. I don't even have command line access to MySQL,
                              I have to use MyPHPAdmin.
                              3) Install rsync (client) in the desktop PC.
                              I guess I would have to install Cygwin, or is there an rsync client for
                              windows?

                              Comment

                              Working...