1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

rename file on download

Discussion in 'PHP' started by Mariam, May 26, 2009.

  1. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Then I upload the file, for example "MG_CV.doc" the php code renames the file to "38912831_7183791.doc" and then uploads it. In database are saved the old and new names of the files (MG_CV.doc, 38912831_7183791.doc).


    After I call
    <a href='MG_CV.doc'>download file</a>
    I need on clicking on "download file" download 38912831_7183791.doc but in "save as dialog" must be "MG_CV.doc" how can I do this in PHP
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    What PHP script uploads your files? How do you serve i.e. allow download of these files through a PHP script or direct download?
     
  3. Mariam

    Mariam New Member

    Joined:
    Sep 9, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Upload script is not necessary. In database I have real name of the file(MG_CV.doc) and renamed file (38912831_7183791.doc).
    The real file that exists in server is 38912831_7183791.doc. I need download 38912831_7183791.doc file.
    I wrote <a href='MG_CV.doc'>download file</a>, by clicking on "download file" must be opened save dialog and be downloaded with this "MG_CV.doc" name
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    To provide the real name for the download either you have keep it in the same name or you have to pass the Content-Disposition header which should include the filename to be shown for Save As
     

Share This Page