SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    0 Post(s)
    0 Thread(s)

    Uploading files with PHP, and storing the filename separately...

    Hello everyone,

    I am hoping that someone may be able to help me with this...what I am trying to do is have a PHP script that will upload PDF files (won't be files of any other type) to a remote server, but I also want to store the filename (e.g. - jukebox.pdf) in the MySQL database running on the server at the same time. I believe that PHP has a variable that stores the filename separately anyway, but I'm just not sure which one it is exactly. I want to store the filename just so that I can concatenate it to the URL of the directory that the PDF file will be in so that when someone does a search, it will display the URL so that they can click a link to it (e.g. - So in summary, I have three, is to define the PDF file properly (would it be /adobe-acrobat PDF or something?), then how to actualy upload the file properly (let the user browse their harddrive and select it, or type in the file location manually), and then how to store the filename, concatenated to the URL (I would imagine having the full URL stored in the database so that it can just be echoed out). Any and all help with this would be very much appreciated.



  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    New Zealand
    0 Post(s)
    0 Thread(s)
    Ok I haven't played with the file upload features before, but you can check them out here:

    I think it might be something like this:
    // rename and save file
    $newFileName = $id . ".dat";
    copy($file, $dataDir . $newFileName);

    This was taken from The Vault which is available from
    So I suggest you pop over there and download The Vault. It is like a paper-less office type script, so you can check documents in and out etc. It handles the tracking of the document names and the file uploading. I think in the articles about it, it describes how to do each of the things.

    Sorry I was on no direct help to your situation.

    Oh, and the stuff you will send will be like:
    header ("Content-Type: adobe stuff");
    Not sure what you put for the PDF files though.


Posting Permissions

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