dcsimg
www.webdeveloper.com
Results 1 to 12 of 12

Thread: Browsing for files from a browser?

  1. #1
    Join Date
    Jan 2010
    Posts
    26

    Browsing for files from a browser?

    I have a tabular html form where users can enter a number of titles and file specifications in columns. Having the users actually ENTER the full filespec (path AND filename) has proven problematic so I'd like to give them a way to browse around the local system on which the browser is running, and select the file. When done, they hit Submit and the filespec get sent to php along with everything else on the form.....

    So far I've gotten lots of "you can't do that" (I stupidly thought the input type="file" would actually work), and found a few javascript samples that MIGHT do it if I could get any of them to work. I CAN'T be the first person ever to need a way for users to do this to upload or email files or whatever. I"m sure I'm missing something important, but I'm astonished there isn't a reasonable way to do this in html.

    First, CAN THIS be done in javascript - Display the form. Show any previously entered values in the fields. Let the user change existing filespecs, enter new filespecs, or browse the system to select filespecs. Put whatever they select in the field. When they hit submit send the filespec (the WHOLE filespec) along with the other data back to php for storage?

    If so, does anyone have a pointer to a good, simple, idiot-proof example? Unfortunately, at this time I know VERY little about javascript, so I need something that can be understood and quickly implemented...

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    This cannot be done in javascript. The file input form element does what you are asking for (though some browsers do not allow for manual textual entry). You won't be able to grab the whole location no matter what method you take (without switching to a Java applet in a signed JAR that reads the file system) since the input=file only sends the file and original name.

    It sounds like you are wanting a multiple file upload table? Why do you need the client side folder path info of the file anyway?

  3. #3
    Join Date
    Jan 2010
    Posts
    26
    Wow. This is really depressing. Its 2010 and I'm finding out just how limited and primitive the Internet environment and tools are. But, it is what it is....

    >It sounds like you are wanting a multiple file upload table? Why do you need the client side folder path info of the file anyway?

    Good question. Let me back up and describe what's going on....

    This is partially automating a currently manual process.
    Photographer wants to enter a competition. They have 1 - n digital images in jpeg files. These image files need to be emailed to the person in charge of the competition. This form provides a way to enter the image title and the file specification, and press a button to email the files as attachments. The person in charge wants a SINGLE email from the competitor, with the list of titles and the set of images.

    I've got the form. I've got the email. The problem is getting the file specifications. Having these users ENTER the entire file spec for every one of their images is going to guarantee a lot of errors, which is why it's desirable to provide an alternative.

    Ideas?

  4. #4
    Join Date
    Jan 2009
    Posts
    3,346
    What do you mean file specifications? Like file size and such?

    You could adjust your process a bit:

    1) Present upload form for a single image
    2) When file upload succeeds present 2 options: Upload another, or complete
    3) If upload another repeat from 1
    4) Else construct email

  5. #5
    Join Date
    Jan 2010
    Posts
    26
    File specification in this case is just the regular filename and path....

    So, if the file is p:\photo\derivatives\drv_080_20081020\some_image_name.jpg
    I want the whole thing because its needed for the email attachment...


    >You could adjust your process a bit:

    >1) Present upload form for a single image
    >2) When file upload succeeds present 2 options: Upload another, or complete
    >3) If upload another repeat from 1
    >4) Else construct email

    How would that resolve the issue of wanting to use a file browser to get the filespec? There's no upload, just a "send an email with your files attached".

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346
    You need to upload the file to the server and attach it to the email sent by your server side processing. You don't need the full path for that at all. How are you sending the email currently (using a mailto href possibly)?

  7. #7
    Join Date
    Jan 2010
    Posts
    26
    Could be another thing I've missed... Currently I'm running everything locally, and using the php "mail" command once I've built the message. I hadn't thought about the problem of once the php is sitting on the web host it doesn't have access to the files sitting on the user's local pc...... Phooey!

    I don't suppose there's anything as useful as an emailer in html or javascript?

  8. #8
    Join Date
    Jan 2009
    Posts
    3,346
    Nope, html and javascript are not viable for sending emails. Using the mail command in PHP is the way to go, however, you'll need to process actually uploading the files to the server at least temporarily to be emailed as I suggested above.

  9. #9
    Join Date
    Jan 2010
    Posts
    26
    OK. I'll just have to persevere in php...... Which is getting more grotesque by the moment.... Now when the user hits the "send email" button they're going to have to wait while 3 - 4 MB of files get uploaded, then wait while the php email does the processing and emails... Yuck...

  10. #10
    Join Date
    Jan 2009
    Posts
    3,346
    As I suggested above it might be best to have them upload all there files before getting to the final step of the process.

  11. #11
    Join Date
    Jan 2010
    Posts
    26
    I understand the idea of copying each file to the server as the user puts in the filespec, but since the form has a fixed number of rows the user can enter all their images before hitting Submit and sending everything to php.

    I'm probably being obtuse, but I can't believe this is the first time in the history of the Internet that someone has needed to get filespecs (full path and filename) and email the files from a user's system. Is there really no simple, standard, straightforward way to browse for filespecs into fields on a form and send the files as email attachments using the user's regular email engine? Or AT LEAST send email from the client-side form with attachments...

    How does everybody else get their users to consistently, accurately enter file information if we can't use a file browser?

    I"m struggling with the whole idea of actually having dozens of users accurately entering filespecs, copying large files (and these are SMALL files at 500K each, a normal image would be larger) from the user's computer up to the web host, have the files sitting around on the web host, sending them as attachments using "mail" (which appears to be synchronous and very slow), and then have to clean up umpteen megabytes of image files that are sitting around taking up space on the web host... There HAS to be a more efficient way.....

    Is my whole process defective? Do I need to do something drastically different?

  12. #12
    Join Date
    Jan 2009
    Posts
    3,346
    It is not plausible to send emails client side from a web page (a Java application or other stand alone client app is a different story). The user would have to wait for the email to be sent (meaning the images would have to upload anyway) whether the email was sent client-side or server-side so that is an invalid argument.
    I can't believe this is the first time in the history of the Internet that someone has needed to get filespecs (full path and filename) and email the files from a user's system.
    This is usually done with an email client application (i.e. Outlook, Thunderbird, etc) not through a web page.
    How does everybody else get their users to consistently, accurately enter file information
    Most people have the user upload files to the server and construct the emails server-side. In fact, it makes the most sense to store the images on the server and only include links to them in the emails...just saying.
    and then have to clean up umpteen megabytes of image files that are sitting around taking up space on the web host
    If you are only appending them to emails you can remove them from the file system as soon as the email is sent.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles