Uploading files into a MySQL database using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #46
    You can simply remove the max_file_size input if it is giving you problems.
    It isn't really needed. PHP has it's own size limits that it uses.

    The max_file_size input is mostly to give the browser a chance to prevent a file upload that is known to be to large.

    Comment

    • roseple
      New Member
      • Jun 2009
      • 26

      #47
      Hi Atli..

      Correct me if I'm wrong.

      Error Code:2 = large file
      Error code:4 = there's no file to upload

      And what is the other error user may encounter using the codes above?
      Thanks..

      Comment

      • roseple
        New Member
        • Jun 2009
        • 26

        #48
        Ooops, I got it. Sorry..

        You posted that already.

        Thanks anyway.

        Comment

        • roseple
          New Member
          • Jun 2009
          • 26

          #49
          Hi Atli,

          Why does the link to the next page of this forum is not visible anymore?

          Thanks..

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #50
            Originally posted by roseple
            Hi Atli,

            Why does the link to the next page of this forum is not visible anymore?

            Thanks..
            I moved some of your posts into their own threads, which made this thread fit into one page again.

            Click the "subscripti ons" link at the top of the page and you should be able to see them.

            Comment

            • roseple
              New Member
              • Jun 2009
              • 26

              #51
              Ok, and thank you very much on all your help.
              Ooops, I just want to ask... Is this uploading codes can support mp4 and mp3 files? I already increase my upload and post_max_size.

              Thanks..

              Comment

              • Atli
                Recognized Expert Expert
                • Nov 2006
                • 5062

                #52
                This code can upload any file, regardless of size, type or extension.

                If your PHP and MySQL setup is set up to handle large file uploads, then this code can process them.

                Comment

                • apple08
                  New Member
                  • Jun 2009
                  • 4

                  #53
                  Hello..

                  Can anyone know why this error is present:
                  Fatal error: Call to undefined function mysqli_connect( ) in c:\Inetpub\wwwr oot\uploading\c onnect.php on line 20
                  Code in line 20:
                  Code:
                  $dbLink = mysqli_connect('localhost', 'root', 'ai3', 'filestorage');
                  Thanks..

                  Comment

                  • apple08
                    New Member
                    • Jun 2009
                    • 4

                    #54
                    Hello..

                    Why does the error "Error, Failed to insert the File."

                    Thank you..

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #55
                      Hi, apple.
                      Originally posted by apple08
                      Hello..

                      Can anyone know why this error is present:
                      Fatal error: Call to undefined function mysqli_connect( ) in c:\Inetpub\wwwr oot\uploading\c onnect.php on line 20
                      Code in line 20:
                      Code:
                      $dbLink = mysqli_connect('localhost', 'root', 'ai3', 'filestorage');
                      Thanks..
                      This error occurs when you try to use a function belonging to an extension that isn't loaded (or doesn't exist).

                      In this case, your PHP installation is missing the Improved MySQL extension
                      See the Installation page in the manual of instructions on how to enable the extension.

                      You can also rewrite the code to use the old MySQL extension, if that is available in your installation.
                      You would just have to rewrite the connection part and remove the "i" from the other functions.

                      Originally posted by apple08
                      Hello..

                      Why does the error "Error, Failed to insert the File."

                      Thank you..
                      That is the error I wrote into my example code in case the SQL query that is supposed to insert the file failed.
                      It should have printed additional information that would be good to have if you want our help debugging this.

                      Comment

                      • apple08
                        New Member
                        • Jun 2009
                        • 4

                        #56
                        Hello,

                        To be specific, the error I encountered was " Error, failed to insert the File. MySQL server has gone away." There are also times that the error was " Error, failed to insert the File. Got a packet larger than the max_allowed_pac ket bytes."

                        That said errors only occur when I tried to upload a file larger than 2Mb.

                        Thank you.

                        Comment

                        • Atli
                          Recognized Expert Expert
                          • Nov 2006
                          • 5062

                          #57
                          That would indicate that you are sending more data than MySQL is willing to accept.

                          You need to alter the MySQL configuration so that it can accept more data.
                          The "max_allowed_pa cket" directive is a good place to start.

                          The MySQL configuration file is named "my.cnf" (or "my.ini", on Windows).
                          It is usually just under the MySQL installation dir, although that can vary based on the installation type.

                          Comment

                          • apple08
                            New Member
                            • Jun 2009
                            • 4

                            #58
                            Hello, do you guys know how I can make the list of my uploaded files become a thumbmails instead of table list?

                            Thanks.

                            Comment

                            • roseple
                              New Member
                              • Jun 2009
                              • 26

                              #59
                              Hi...

                              I just want to ask why does my server is too slow whenever I upload a quite large fie. Is it because I save the file to the database.

                              Thank you....

                              Comment

                              • msei
                                New Member
                                • Mar 2009
                                • 6

                                #60
                                Hi,

                                I have a question about the list files, Is there a way to list only the field TYPE ='FYR' instead list all the record. Any help will be appreciated.

                                Thank you in advance.

                                msei

                                Comment

                                Working...