how to get file name with type = "file",without path only filename from remot server(linux server) ?

for example:

<input type="file" size="30" name="filename">

how to get only filename  no path from remot server(linux   server path) , how to  change  the  file of path ,because  input type set    "file"  is  get localhost  path. 

please give me for am example thank!!!

    Originally posted by bobthedog
    [man]basename/man ??

    i want use the button to select the file from the linux server
    then select the file without the path only the file name then save the file name to mysql table of filed.

      Ok -

      So after your browser has uploaded the file (i'm guessing), you will want to get the filename of it, then save that filename to MySQL.

      Well - I'm not writing all the code for you - but here are some pointers.

      1, If you are uploading a file via a web browser, then the file exists for as long as your script is running. PHP then performs a clean up and your file is destroyed. To overcome this, you have to copy the file out of the temporary directory and (optionally) give it a name.

      2, To get the filename part of a complete path and filename string, use

      $strFilename = basename($strPath);
      

      $strFilename will then contain only the filename from your path, and all path information will be discarded (although it is still available from the $strPath variable).

      3, You need to have a MySQL table to put the filename into. You will probably want a primary key (especially if you allow duplicate filenames in your table), and a filename column (I assume the path is consistent for all files).

      4, Insert a row into your table i.e.

      $result = mysql_query('INSERT INTO files (filename) VALUES ("' . $strFilename . '")');
      

      or something like that anyhow.

      So - hope that helps you 🙂

        Originally posted by bobthedog
        Ok -

        So after your browser has uploaded the file (i'm guessing), you will want to get the filename of it, then save that filename to MySQL.

        Well - I'm not writing all the code for you - but here are some pointers.

        1, If you are uploading a file via a web browser, then the file exists for as long as your script is running. PHP then performs a clean up and your file is destroyed. To overcome this, you have to copy the file out of the temporary directory and (optionally) give it a name.

        2, To get the filename part of a complete path and filename string, use




        $strFilename = basename($strPath);
        

        $strFilename will then contain only the filename from your path, and all path information will be discarded (although it is still available from the $strPath variable).

        3, You need to have a MySQL table to put the filename into. You will probably want a primary key (especially if you allow duplicate filenames in your table), and a filename column (I assume the path is consistent for all files).

        4, Insert a row into your table i.e.

        $result = mysql_query('INSERT INTO files (filename) VALUES ("' . $strFilename . '")');
        

        or something like that anyhow.

        So - hope that helps you 🙂 [/B]

        thank!!

        but i want to select filename is from remote server (isp) not im
        i local path. how to write,because file already uploaded .only
        i want to select i uploaded to isp the filename save to table of filed.please for example
        ,

          Write a Reply...