Download file from database ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tinus
    New Member
    • Jul 2010
    • 30

    Download file from database ?

    Hi

    I have follwed the steps as in the thread "Uploading files into a MySQL database using PHP "

    Everything is going very well until I try to download the file.

    It is tellin me:
    Error! No ID was passed.

    I do not understand why as the file was defenitly uploaded.

    Hope you can help.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    That error means you are not passing an ID to the download scripts. The URL of the download links should look something like: example.com/get_file.php?id=5

    The problem is most likely in the list_files.php script. Post it here and we'll take a look at it for you.

    Comment

    • Tinus
      New Member
      • Jul 2010
      • 30

      #3
      Thanks.It worked.

      Now I am having trouble with viewing the file.
      The file is stored as a longblob.
      It gives me the option to safe or open the file ,but then when I try to open the jpeg( with windows picture viewer) nothing is displayed.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        If you save it, does it work?
        If not, how big is the file (exactly, in bytes), and is there a difference from the size it is in the database?

        Note that if there is an error in the PHP code that retrieves the file, you will not see it as text. It will be printed as, or as a part of, the data for the image. In those cases you can set the Content-Type header back to text/plain or text/html to view it in your browser.

        Comment

        • Tinus
          New Member
          • Jul 2010
          • 30

          #5
          The file size indicated in the database and the size of the saved file is the same

          I have downloaded another image that opens but it has lost some of its quality.
          size=1862 bytes

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            If you set the content-type of the download script to "text/plain" and comment out the line that prints the actual data, does anything print to the browser?

            Comment

            Working...