Results 1 to 5 of 5

Thread: Browsing button !

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Location
    Viet Nam
    Posts
    142

    Browsing button !

    I am Trying do do a work of reading content of a file using PHP . I now know nothing to code .At first how how to have a button in javascript to open the file open dialog , so that the user can choose which file to open , and then when the user has selected a file , how do the codes look like to read the content of that file to a variable ?
    I am new with PHP and javascript . Please tell me how .

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    This has nothing to do with JavaScript. You need a form with some encoding type I forgot that contains a <input type="file" />. This input consists of the edit box that shows the path and the button to bring up the selection dialog.

    In PHP there is a global variable, formerly named $HTTP_POST_FILES but now surely some $_ name, that contains information about the uploaded file. The most important of course is the file name of the temporary file that was created on the server. This file you can load and read or copy somewhere, whatever you want.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Location
    Viet Nam
    Posts
    142
    so it will upload on the server ? but then what name it will be , actually i don't want it to upload , i just want the contain of that file then that's all .
    the $_name will it be the name in the tag input type ="file" , can u tell me more clear ?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There is little difference between a file and its content...

    The filename is irrelevant, it's some constructed name in a temporary directory. If you only want the content then read it in and forget about the file, it's deleted once the script ends.

    If you want to keep the file you must copy it to a different location.

    No, I guess $_FILES but you need to look it up in the PHP reference.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    to gets the contents of that file it is best to upload it. but it really all depends on what you are using it for. look at the manual as they have a prety good section on file uploads and what code to use.

Posting Permissions

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



Click Here to Expand Forum to Full Width