How to upload a file using a form

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • davidundalicia
    General

    • Mar 2006
    • 6294

    #16
    Re: How to upload a file using a form

    I also would like to see a mod to upload multiple files.............
    Have fun
    Regards..... David

    Step by Step Visual Tutorials for the complete beginner
    Newbies / Beginners Forum
    FREE Membership Login Scripts: - Meta Tags Analyzer
    My Social Networking Site - Free Contact Forms
    Finished your New website!! Now get it noticed Here:

    Comment

    • navaldesign
      General & Forum Moderator

      • Oct 2005
      • 12080

      #17
      Re: How to upload a file using a form

      Originally posted by davidundalicia
      I also would like to see a mod to upload multiple files.............
      UPLOADING MULTIPLE FILES

      Ok, here is a script for uploading two files. The same structure can be adopted for multiple files, repeating the blocks as they appear in the script.
      Please note that this script follows the same logical structure of the single upload field one, but with some additional checking: f.e. the size error checking has to be done for both upload fields BEFORE the script starts uploading. Then it has to check again, field by field, before it starts the real upload, otherwise you could have error headers sent out and the script broken, if f.e. one of the two fields is empty.
      Please note that this is NOT what i would have used: a would have used a include file to minimise scripting. However, this would exceed the capabilities of the average user, as it would require more php files to be compiled and uploaded. This way instead, it is pretty straight.


      <?php
      // Receiving variables
      @$email = addslashes($_POST['email']);
      @$upload_Name = $_FILES['upload']['name'];
      @$upload_Size = $_FILES['upload']['size'];
      @$upload_Temp = $_FILES['upload']['tmp_name'];
      @$upload1_Name = $_FILES['upload1']['name'];
      @$upload1_Size = $_FILES['upload1']['size'];
      @$upload1_Temp = $_FILES['upload1']['tmp_name'];

      // Validation for max file size

      // Validation for the first file, if it exists. Repeat the block as many times as your upload fields.

      if ($upload_Size>0)
      {
      if( $upload_Size >1000000)
      {
      //delete file
      unlink($upload_Temp);
      header("Location: error.html");
      exit;
      }
      }

      // Validation for the second file, if it exists. In the additional blocks, change the number 1 to 2 or 3 or ... n

      if ($upload1_Size>0)
      {
      if( $upload1_Size >1000000)
      {
      //delete file
      unlink($upload1_Temp);
      header("Location: error.html");
      exit;
      }
      }
      // Uploading the first file, if it exists. Repeat as many times as your upload fields.

      if ($upload_Size>0)
      {
      $uploadFile = "uploads/".$upload_Name ;
      @move_uploaded_file( $upload_Temp , $uploadFile);
      chmod($uploadFile, 0644);
      $upload_URL = "http://www.yourdomain.com/uploads/".$upload_Name ;

      // Uploading the second file, if it exists.

      if ($upload1_Size>0)
      {
      $uploadFile = "uploads/".$upload1_Name ;
      @move_uploaded_file( $upload1_Temp , $uploadFile);
      chmod($uploadFile, 0644);
      $upload1_URL = "http://www.yourdomain.com/uploads/".$upload1_Name ; // You must change the number 1 to 2 or 3 or whatever in the additional blocks
      }
      //Sending Email to form owner
      $mailto = "youremail@yourdomain.com";
      $mailsubj = "Enter Your Subject Here";
      $mailhead = "From: $email\n";
      reset ($HTTP_POST_VARS);
      $mailbody = "Values submitted from web site form :\n";
      while (list ($key, $val) = each ($HTTP_POST_VARS))
      {
      if ($key!="submit")
      {
      $mailbody .= "$key : $val\n";
      }
      }
      $mailbody .= "File Link 1: $upload_URL\n"; // This line is to add the link to the first file. Repeat as many times as your upload fields
      $mailbody .= "File Link 2: $upload1_URL\n"; // This line is to add the link to the second file.

      $mailbody .= "If any link is broken, please copy and paste it in your browser's address bar\n";

      mail($mailto, $mailsubj, $mailbody, $mailhead);

      // Autoresponder: if you don't want the autoresponder, delete this and the following 7 lines in Green color



      if ($Copy != "")
      {
      $mailto = $email;
      $mailsubj = "Copy of the info you Submitted";
      $mailhead = "From: put your site or company name here: \n";
      mail($mailto, $mailsubj, $mailbody, $mailhead);
      }




      header("Location: thankyou_page.html");

      ?>

      As always change the part s in blue to be your own details. The blocks can be repeated as many times as you want, to include as many upload fields as you want. The fields in the form should be named: upload, upload1, upload2, upload3, ...... upload(n) where n is the last field.

      You can test the form here. If you tick the small bottom check box, you will receive a copy email of the info submitted, with the file kinks, so you can check yourself how the script works.
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment

      • 5thmsstech
        Corporal

        • Aug 2006
        • 12

        #18
        Re: How to upload a file using a form

        Voda just plain ROCKS!!! thanks for the help im going to try this out. But was thinking, instead of letting them do multiple files at once and having to wait for them all to upload (risking them giving up). I might just add a "upload additional file form to the thankyou page.

        Comment

        • davidundalicia
          General

          • Mar 2006
          • 6294

          #19
          Re: How to upload a file using a form

          Very useful upload options, have installed and it worked first time.............

          Well done *****, and Naval.

          Naval, is it posible for you to email me the required code for your multiple forms project? I have looked at it twice and would now like to see it in its finshed form. Is that posible ? If so, then I will look forward to seeing it when I get back from my holiday(returning from Italy(Farinjana) 14th sep)

          have fun
          Have fun
          Regards..... David

          Step by Step Visual Tutorials for the complete beginner
          Newbies / Beginners Forum
          FREE Membership Login Scripts: - Meta Tags Analyzer
          My Social Networking Site - Free Contact Forms
          Finished your New website!! Now get it noticed Here:

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #20
            Re: How to upload a file using a form

            Ok David, but there is nothing more than what i posted in that thread.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment

            • davidundalicia
              General

              • Mar 2006
              • 6294

              #21
              Re: How to upload a file using a form

              I would be interested in seeing how the code can take you from page to page at the review stage and also what results were sent to the client.

              It looks pretty good to me and I could posibly use almost the exact forms and content for another of our forum members.

              You are a gentleman naval and one of the main springs of these forums.

              Hasta la vista amigo mio..............until the next time my friend.......
              Have fun
              Regards..... David

              Step by Step Visual Tutorials for the complete beginner
              Newbies / Beginners Forum
              FREE Membership Login Scripts: - Meta Tags Analyzer
              My Social Networking Site - Free Contact Forms
              Finished your New website!! Now get it noticed Here:

              Comment

              • navaldesign
                General & Forum Moderator

                • Oct 2005
                • 12080

                #22
                Re: How to upload a file using a form

                Mails sent David
                Navaldesign
                Logger Lite: Low Cost, Customizable, multifeatured Login script
                Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                Comment

                • davidundalicia
                  General

                  • Mar 2006
                  • 6294

                  #23
                  Re: How to upload a file using a form

                  emails received with many thanks.....
                  Have fun
                  Regards..... David

                  Step by Step Visual Tutorials for the complete beginner
                  Newbies / Beginners Forum
                  FREE Membership Login Scripts: - Meta Tags Analyzer
                  My Social Networking Site - Free Contact Forms
                  Finished your New website!! Now get it noticed Here:

                  Comment

                  • navaldesign
                    General & Forum Moderator

                    • Oct 2005
                    • 12080

                    #24
                    Re: How to upload a file using a form

                    You are welcome
                    Navaldesign
                    Logger Lite: Low Cost, Customizable, multifeatured Login script
                    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                    Comment

                    • navaldesign
                      General & Forum Moderator

                      • Oct 2005
                      • 12080

                      #25
                      Re: How to upload a file using a form

                      To anyone interested: A more elegant code for uploading multiple files, can be found in http://www.vodahost.com/vodatalk/for...form-help.html
                      Navaldesign
                      Logger Lite: Low Cost, Customizable, multifeatured Login script
                      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                      Comment

                      • ekeeler
                        Corporal

                        • Aug 2006
                        • 14

                        #26
                        Re: How to upload a file using a form

                        Hi,
                        I've built my first website and everything works fine in preview and on my home pc. However, my stepson, who is beta testing my site repots that my contact page is not working. I downloaded the free contact form that David advertised as it suits my needs perfectly. Mal reports that when he goes to the contat page, he cannot enter a name. It just won't accept it, and he gets the error message. Any suggestions? The site is www.sidrheuban.com. Thanks, Elaine
                        Elaine K Keeler

                        Comment

                        • navaldesign
                          General & Forum Moderator

                          • Oct 2005
                          • 12080

                          #27
                          Re: How to upload a file using a form

                          It worked fine for me, however your Comments fiels is (maybe) covered by something, because i could not directly click on it to type in. However, no error messages.
                          Navaldesign
                          Logger Lite: Low Cost, Customizable, multifeatured Login script
                          Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                          DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                          Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                          Comment

                          • ekeeler
                            Corporal

                            • Aug 2006
                            • 14

                            #28
                            Re: How to upload a file using a form

                            Thank you for checking this. I noticed the problem with getting the cursor to appear in the comments box. I can't find anything overlaying it. A cursor does appear if you click on the scroll bar and then everything works fine, for me at least. Perhaps Mal's problem has something to do with his web browser. I read that someone was having trouble with some of the fields and a response was that Yahoo may be causing it. Maybe I need another beta-tester!
                            Elaine
                            Elaine K Keeler

                            Comment

                            • navaldesign
                              General & Forum Moderator

                              • Oct 2005
                              • 12080

                              #29
                              Re: How to upload a file using a form

                              Please select the form fields, one at a time, and bring them in front. Then save your page and publish again.
                              Navaldesign
                              Logger Lite: Low Cost, Customizable, multifeatured Login script
                              Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                              DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                              Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                              Comment

                              • navaldesign
                                General & Forum Moderator

                                • Oct 2005
                                • 12080

                                #30
                                Re: How to upload a file using a form

                                Also, do NOT set the fields background to be transparent. This, some times, has this effect.
                                Navaldesign
                                Logger Lite: Low Cost, Customizable, multifeatured Login script
                                Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                                DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                                Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                                Comment

                                Working...
                                X