Results 1 to 98 of 98

Thread: How to upload a file using a form
      
   

  1. #1
    Join Date
    Mar 2005
    Location
    Wilmington, Delaware USA
    Posts
    12,280

    Talking How to upload a file using a form

    The following tutorial will show you how to accomplish file uploads. However, since September 2006, the new Advanced BlueVoda Form Processor will do the same and much more. So please have a look at that also. And, since Jan 2007, ABVFP will also attach the files to the email that you receive with th erest of the form info.

    Please also note that since summer 2008 BlueVoda's embedded Form processor, also has the ability to upload files to the server, and it will include the link to download the files, in the mail that you receive with the rest of the form info.

    This tutorial is going to show you how to upload a file on your site using a form made in BlueVoda and a php script.
    We assume that you are familiar with the basics about creating a form in BlueVoda, as well as with the basic php script provided there. If you are not, please read first the BlueVoda Form Tutorial 1

    The below is an example of PHP script you may use for processing your forms data and uploading single files.. Please follow the instructions that follow to the letter. Please note that this is only an example script, that can be customized to better suit your needs.

    Let’s start by explaining what we will do:
    • We will create a form in BlueVoda.
    • We will create a php script to process our form. Since we usually want a size limit for the files to be uploaded, this script will also check the file size, and if bigger than what we have set as maximum, will redirect the visitor to an error page. When informed about the error, he can use a “Back to form” button, to return to the form.
    • The script will also send an email to our email address, to inform us that a new file has been uploaded, and will provide us the link to this file.
    • We will create a “Thankyou Page, to inform our visitor that his file has been uploaded.
    • We will also create the necessary folder, where uploaded files will reside.
    The working plan of our procedure is like in the following image:




    Let’s start by creating a form. It will have some contact information, as well as an upload field.

    It will look like the following image:




    Please note that, in order to have the form work with the script as it is, the email field MUST be called email” and the upload field MUST be called upload”. It is also advisable that you name your Submit button "submit", all lowercase letters, as we have implemented three lines of code that will take care NOT TO INCLUDE the Submit button title and value, but this code will only work if the button is named "submit".
    Set the form properties in:

    Form name: Uploadform
    Action: uploadaction.php
    Method: POST
    Encoding Type: multipart/formdata

    As shown in the following image:





    Now, let’s create the php script that will do the work.

    Please copy the following code:

    <?php

    // Receiving variables

    @$email = addslashes($_POST['email']);
    @$upload_Name = $_FILES['upload']['name'];
    @$upload_Size = $_FILES['upload']['size'];
    @$upload_Temp = $_FILES['upload']['tmp_name'];


    // Validation for max file size

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

    @move_uploaded_file( $upload_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload_URL = "http://www.yourdomain.com/uploads/".$upload_Name ;
    }

    //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 .= "upload: $upload_URL\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);

    header("Location: thankyou_page.html");

    ?>
    Please note that there are four parts in blue in the above code.

    Open Notepad. Paste the above code. Now, change the above four parts in Blue with your actual values:

    1000000 is the limit file size, in bytes ( 1 Mb = 1000000 bytes). You can set it to be whatever you want.
    http://www.yourdomain.com/uploads is yourdomain name and folder (uploads) where the file will be uploaded. Please do not change the "uploads" part, as you would also need to modify the script.
    Enter Your Subject Here : this is the email subject, change it to whatever you want.
    Values submitted from web site form : : is the first line of your email. Change it to whatever you like.

    Once you are done with the changes, click on File, Save As, select File Type : All files, and save the script on your computer as “uploadaction.php

    Now lets create the Thankyou page. It will be a simple BV page, and will look like the following:




    Make sure to put your menubar in this page, so the visitors can go on navigating your site.

    Ok, we now need the error page: We will also create it in BV, and it will look as follows:




    Make sure to
    • Include your menubar: so, if the visitor CANNOT reduce his file size under the allowed limit, he will at least be able to continue navigating your dite.
    • Add a “Back to form” button. This one is easy. Select from the form toolbar, in BV, “Advanced”, double click the text to make it “Back to form”, then right click it and select Properties, just like in the image below:
    In the Advanced Button properties window that will appear, select the following (as in the image)


    Name: optional, “Back”
    Value: optional, “Back”
    Button Type: “On Click”
    OnClick Action: “Go to the previous Page”
    just like in the image below:


    If you wish you can also change the button style, but this goes beyond this tutorial purposes.


    So, now you have the following BV pages:
    • uploadform
    • thankyou_page
    • error
    Publish these pages in your public_html folder.

    Open BlueFTP, connect, and UPLOAD the “uploadaction.php” file that you created in Notepad, in public_html also.

    There is ONE LAST STEP: you need to create the “uploads” folder, for the files to be uploaded. So while you are in BlueFTP, click anywhere on the right window (the one with your site content). Now click on File, New Folder, and create this new folder named “uploads”. If you name it anything else, you will need to change the script accordingly. Now right click your new created folder, and set the permissions to 777.

    Congratulations! You are done. Test your form.

    Troobleshooting:

    If the filename has blank spaces, the URL of the file that you will receive in your email, will be broken. In that case, clicking on the link will not work. You need to either download the file from your site using BlueFTP, or, if you want to see the file in your browser, you will need to copy the entire link in your browser’s address bar.





    VodaHost

    Your Website People!
    1-302-283-3777 North America / International
    02036089024 / United Kingdom
    291916438 / Australia

    ------------------------

    Top 3 Best Sellers

    Web Hosting - Unlimited disk space & bandwidth.

    Reseller Hosting - Start your own web hosting business.

    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)



  2. #2
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,294

    Default Re: How to upload a file using a form

    I can see that your not a L.G. for nothing

    Thats a great tip, and will try it out soon.

    Thanks *****..

  3. #3
    Join Date
    Oct 2005
    Location
    England, UK
    Posts
    4,193

    Thumbs up Re: How to upload a file using a form

    Nice one, Mon General!!
    Last edited by VodaHost; 05-13-2006 at 05:01 PM.

    VodaHost

    Your Website People!
    1-302-283-3777 North America / International
    02036089024 / United Kingdom
    291916438 / Australia

    ------------------------

    Top 3 Best Sellers

    Web Hosting - Unlimited disk space & bandwidth.

    Reseller Hosting - Start your own web hosting business.

    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)



  4. #4
    Join Date
    Jul 2006
    Posts
    1

    Default Re: How to upload a file using a form

    wow thanks! your the man, thanks for the tip it will definetly help out.

    Raf..

  5. #5
    Join Date
    Jun 2005
    Location
    Wirral, England
    Posts
    50

    Talking Re: How to upload a file using a form

    Now that Navaldesign has sorted out my form problem, I have another question. Is there any way that when someone uploads a file an automated e-mail is sent to them confirming that the file has been received? Almost like a receipt?

    Thanks again Navaldesign!

  6. #6
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Yes, transform the above script as follows:

    <?php

    // Receiving variables


    @$email = addslashes($_POST['email']);
    @$upload_Name = $_FILES['upload']['name'];
    @$upload_Size = $_FILES['upload']['size'];
    @$upload_Temp = $_FILES['upload']['tmp_name'];


    // Validation for max file size

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

    @move_uploaded_file( $upload_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload_URL = "http://www.yourdomain.com/uploads/".$upload_Name ;
    }

    //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 .= "upload: $upload_URL\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);

    // Autoresponder
    $mailto = $email;
    $mailsubj = "Copy of the info you Sumbitted";
    $mailhead = "From: your domain name or whatever you want\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);

    header("Location: thankyou_page.html");

    ?>


    As usual, replace the part in blue with your own Subject and "From....."
    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!


  7. #7
    Join Date
    Aug 2006
    Posts
    1

    Default Re: How to upload a file using a form

    i have looked at this and done what it saids to do but i still can not get it to work i made the form but i dont get what is next can anyone help me make this page.i dont understand php

  8. #8
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Quote Originally Posted by jbyrd241
    i have looked at this and done what it saids to do but i still can not get it to work i made the form but i dont get what is next can anyone help me make this page.i dont understand php
    If you have built the form correctly, and you have published it, the next step is to build the "error" and "thankyou_page". Save them and publish them. Last, copy the above code in Notepad. Change the part in blue as per instructions. Save it as "uploadaction.php" on your computer. Use BlueFTP to upload it on your site.
    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!


  9. #9
    Join Date
    Nov 2005
    Location
    Surrey, UK
    Posts
    43

    Default Re: How to upload a file using a form

    *****,

    yet another great resource for us to use.

    thanks
    Stevea

  10. #10
    Join Date
    Mar 2006
    Location
    UK
    Posts
    50

    Default Re: How to upload a file using a form

    Yet another great Tutorial. This Forum has got to be 'THE FOUNT OF ALL KNOWLEDGE'!

    My thanks to you all!

    Brian

  11. #11
    Join Date
    Aug 2006
    Location
    Midwest
    Posts
    10

    Default Re: How to upload a file using a form

    Can you spell out the upload to the public_html from notepad part in fine detail for a complete and total nubeee? Please and Thankyou!

  12. #12
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Open Notepad. Paste the above code. Now, change the above four parts in Blue with your actual values:

    1000000 is the limit file size, in bytes ( 1 Mb = 1000000 bytes). You can set it to be whatever you want.

    http://www.yourdomain.com/uploads is yourdomain name and folder (uploads) where the file will be uploaded. Please do not change the "uploads" part, as you would also need to modify the script.
    Enter Your Subject Here : this is the email subject, change it to whatever you want.
    Values submitted from web site form : : is the first line of your email. Change it to whatever you like.

    Once you are done with the changes, click on File, Save As, select File Type : All files, and save the script on your computer as “uploadaction.php

    I suggest that you save it inside your BlueVoda folder.

    Sorry, but don't know how to make it simpler. Editing apart, the procedure is only 3 clicks.

    As for the uploading part, open BlueVoda. Click on Tools, FTP Manager.

    BlueFTP will appear, and your screen has your computer BlueVoda folder content in the left part.

    Click on connect. If necessary, type in your IP, username and password, and click "connect". Now, the site content will appear in the right part of the screen.

    Go to the left side, find the "uploadaction.php" file, and simply Drag and Drop it to the right part of the screen.
    You are done!
    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!


  13. #13
    Join Date
    Aug 2006
    Location
    Midwest
    Posts
    10

    Default Re: How to upload a file using a form

    Thanks Navaldesign! I got it figured out.

  14. #14
    Join Date
    Jul 2006
    Posts
    3

    Smile Re: How to upload a file using a form

    Hi Lt. General,

    Please let me know what do you need to help me out on how to fix this script. I have my web page already complete but not able to launch because the image upload.

    Thank you,
    Edwin
    cardone@coqui.net

  15. #15
    Join Date
    Aug 2006
    Posts
    12

    Default Re: How to upload a file using a form

    lol ty bud named folder upload instead of uploads. it works great now

  16. #16
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,294

  17. #17
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Quote 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!


  18. #18
    Join Date
    Aug 2006
    Posts
    12

    Default 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.

  19. #19
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,294

    Default 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

  20. #20
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  21. #21
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,294

    Default 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.......

  22. #22
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  23. #23
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,294

  24. #24
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  25. #25
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  26. #26
    Join Date
    Aug 2006
    Posts
    14

    Post 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

  27. #27
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  28. #28
    Join Date
    Aug 2006
    Posts
    14

    Post 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

  29. #29
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  30. #30
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default 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!


  31. #31
    Join Date
    Aug 2006
    Posts
    14

    Default Re: How to upload a file using a form

    Great, thanks. It all works fine now. Even my stepson can do it!
    Elaine
    Elaine K Keeler

  32. #32
    Join Date
    Nov 2006
    Posts
    179

    Default Re: How to upload a file using a form

    I have a problem with this.
    My website is http://www.ffaproam.com/
    And the upload page is http://www.ffaproam.com/uploadform.php
    My problem is, when someone fills out the info and clicks submit it works fine but the file doesnt get uploaded or anything. I have used BlueFTP and made a file in public_html called uploads. I made its permision777. I added the php script in notepad, editied it, and put that into public_html using BlueFTP. Also, when I get the e-mail after someoen fills out the upload form, it has their video name, e-mail, but where the upload link is it looks like this basicly:
    Video Name:Test
    E-mail:Jackshinta@ffaproam.com
    upload:

    Upload is blank

  33. #33
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Please look at the other thread you have posted. And post here the php script code.
    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!


  34. #34
    Join Date
    Nov 2006
    Posts
    179

    Default Re: How to upload a file using a form

    <?php

    // Receiving variables

    @$email = addslashes($_POST['email']);
    @$upload_Name = $_FILES['upload']['name'];
    @$upload_Size = $_FILES['upload']['size'];
    @$upload_Temp = $_FILES['upload']['tmp_name'];


    // Validation for max file size

    if ($upload_Size>0)
    {
    if( $upload_Size >200000000)
    {
    //delete file
    unlink($upload_Temp);
    header("Location: error.html");
    exit;
    }
    $uploadFile = "uploads/".$upload_Name ;

    @move_uploaded_file( $upload_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload_URL = "http://www.ffaproam.com/uploads/".$upload_Name ;
    }

    //Sending Email to form owner

    $mailto = "jackshinta@ffaproam.com";
    $mailsubj = "Video Upload";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "Video Upload Details :\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    $mailbody .= "upload: $upload_URL\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);

    header("Location: thankyou_page.html");

    ?>
    OK Here's that php script you have asked for!

  35. #35
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Ok, your problem is very simple: you have renamed your upload field, in the form, in "uploadfile" while in the script is "upload". That is why you don't get a value or actual upload. Rename it back to "upload" and it should work.

    Also, please note that php will not allowyou to upload files bigger than 52 MB (you have set it to 200 MB). Files bigger than 52 MB can only be FTPed
    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!


  36. #36
    Join Date
    Nov 2006
    Posts
    179

    Default Re: How to upload a file using a form

    Thank you so much navaldesign!!!!!!!!!!!
    You rock my socks off!!!!!!!!!
    YAY Now My clan Members can upload their montages!!
    THIS IS THE ULTIMATE FORUNTAIN OF KNOWLEDGE!!!

  37. #37
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Please note that you have published the corrected form as php. Correct the extension back to html 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!


  38. #38
    Join Date
    Nov 2006
    Posts
    179

    Default Re: How to upload a file using a form

    Another question. Ive set the upload to 200mb max. Is there anyway I can add a gile upload progress bar? maybe one that pops up inot a new window which states how much the progress the file is in uploading and the file name? similiar to useruploads.mythica.org??

  39. #39
    Join Date
    Nov 2006
    Posts
    179

    Default Re: How to upload a file using a form

    uhh can anyone please help?
    Clan FFA-Halo 2 MLG, Machinima, and Glitch Clan
    http://www.ffaproam.com/

  40. #40
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    A progress bar requires the use of Javascript and AJAX together with PHP. I have only found one script on the net about this, but seems that the relative download link is no more functioning.
    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!


  41. #41
    Join Date
    Dec 2006
    Posts
    2

    Default How To Prevent Files From Being Overwritten

    I know in frontpage you can set folder properties so file uploads can not overwrite existing files. If a uploaded did this the form would redirect them to an error page stating to rename the file and try again.

    I am trying to get away from using frontpage, so I used your code from above to modify my form. I had to combine some of the validation to get it to work... I kept getting an Parse error: parse error, unexpected $ in the last line.

    However, I'm affraid that some people may have the same file name when uploading photos... Is their something I can add to the script to prevent overwriting and a possible error page telling them how to correct the problem. Or even a number being automaticly added to the file name.

    Is it possible to send the information to a file on the server too? Thanks for the help in advance. I'll send you a digital music coupon.

    Here is my form:
    http://www.capitalareaapartments.com/uploadform.htm

    Code:

    <?php
    // Receiving variables
    @$email = addslashes($_POST['email']);
    @$upload1_Name = $_FILES['upload1']['name'];
    @$upload1_Size = $_FILES['upload1']['size'];
    @$upload1_Temp = $_FILES['upload1']['tmp_name'];
    @$upload2_Name = $_FILES['upload2']['name'];
    @$upload2_Size = $_FILES['upload2']['size'];
    @$upload2_Temp = $_FILES['upload2']['tmp_name'];
    // Validation for max file size
    if ($upload1_Size>0)
    {
    if( $upload1_Size >1000000)
    {
    //delete file
    unlink($upload1_Temp);
    header("Location: error.html");
    exit;
    }
    $uploadFile = "uploads/".$upload1_Name ;
    @move_uploaded_file( $upload1_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload1_URL = "<A href="http://www.capitalareaapartments.com/uploads/".$upload1_Name">http://www.capitalareaapartments.com/uploads/".$upload1_Name ;
    }
    if ($upload2_Size>0)
    {
    if( $upload2_Size >1000000)
    {
    //delete file
    unlink($upload2_Temp);
    header("Location: error.html");
    exit;
    }
    $uploadFile = "uploads/".$upload2_Name ;
    @move_uploaded_file( $upload2_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload2_URL = "<A href="http://www.capitalareaapartments.com/uploads/".$upload2_Name">http://www.capitalareaapartments.com/uploads/".$upload2_Name ;
    }
    //Sending Email to form owner
    $mailto = "sales@capitalareaapartments.com";
    $mailsubj = "Ad Listing";
    $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 .= "upload1: $upload1_URL\n";
    $mailbody .= "upload2: $upload2_URL\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    header("Location: orderconfirm.htm");
    ?>


    Thank you for the code, it was the only site that explained it perfectly!!!
    -Tony

  42. #42
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Yes, there are scripts that will make an incremental saving. Since this is only a forum for our members, not for programming talk, we do no go so deep in the scripts that we post. Go in php.net and see the upload function parametres, i beleive there are some examples of how to make incremental save.

    Now, as for your script, it seems correct (apart the part that has been modified by this forum's text editor, pursing links even when it shouldn't)

    Does the script get to upload the files and send the mail ? or doesn't it ?

    And yes, you can write the data in a file on your server. I simply never use this method, as i prefer storing all the info in a database. The database approach allows for research features, dynamic resizing of the images, realtime registration of the users, anyminute editing possibilities, payment followup, etc. But this exceeds the tutorial's purposes.
    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!


  43. #43
    Join Date
    Dec 2006
    Posts
    2

    Default Re: How to upload a file using a form

    Quote Originally Posted by navaldesign
    Now, as for your script, it seems correct (apart the part that has been modified by this forum's text editor, pursing links even when it shouldn't)

    Does the script get to upload the files and send the mail ? or doesn't it ?

    And yes, you can write the data in a file on your server. I simply never use this method, as i prefer storing all the info in a database. But this exceeds the tutorial's purposes.


    Yes, it uploads the file and sends the email containing the links to the photos. I've spent countless hours trying to get a php form to work... got yours to work in 10 minutes. Thanks... I'll take a look at the php site. I didn't even realize you are in Italy!

  44. #44
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    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!


  45. #45
    Join Date
    Aug 2007
    Posts
    2

    Default Re: How to upload a file using a form

    Quote Originally Posted by navaldesign View Post
    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.

    Hi, Having some trouble getting this script to run, the single upload version works fine, however this one fails on the rediret, both on the error redirect and the thank you one.

    I get the following message:

    Parse error: syntax error, unexpected $end in /home/gopriva1/public_html/test/uploadaction.php on line 93

    Yet if I switch back to the single upload version all works fine. Am I missing sometihng?

    Many thanks
    Chris

  46. #46
    Join Date
    Aug 2007
    Posts
    2

    Default Re: How to upload a file using a form

    AHA!

    I think i've got it working now, didn't notice the form tony had posted, once I edited the links and updated the form field names it works a treat.

    Thanks tony et all.

  47. #47
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Why don't you use ABVFP ? it will take care of as many uploads you like, and will also attach the files to the email that you will receive. It also allows autoresponder, multiple choice dropdowns and a lot more. And, if you want, it will also store the form info in a database.
    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!


  48. #48
    Join Date
    Aug 2007
    Location
    USA
    Posts
    46

    Default Re: How to upload a file using a form

    I was able to set up a dwnload link. The only problem is the file begins to play once dwnloaded. The file I have is a Flash MC file to be used for websites. Is there a way to have it dwnload onto the users desktop as a file to be used later?

  49. #49
    Join Date
    Aug 2007
    Posts
    4

    Default Re: How to upload a file using a form

    Could someone let me know what I did wrong? I got everything to work right except on the thank you page, a bunch of script appears at the very top (from the uploadaction.php part).

    Everything works except that (the form, the file upload, the thank you page... ). I don't know anything about code, so I don't want to start messing with what I don't know how to read.

    www.TreasuredXpressions.com/Order.html
    which leads to www.TreasuredXpressions.com/thankyou_page.html


    Thanks in advance...

  50. #50
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,317

    Default Re: How to upload a file using a form

    Will'smom,

    You have placed php code inside the thank_you.html page and that is why it is showing up. The action of the form is set to uploadaction.php and this is where the php code should be. At first glance, I would say simply delete any php code that you have placed in the thank_you.htmll page and it should be ok.

    First- can you give the url of the instructions you followed to get this far?
    We will take a look at it and then go from there.

    Andy
    PHP- is a blast!

  51. #51
    Join Date
    Aug 2007
    Posts
    4

    Default Re: How to upload a file using a form

    Thank you so much. It was about midnight last night when I was working on that and I was getting so frustrated...then I forgot my password into the forums and got locked out.
    Anyway, I forgot that I accidently put the script in the thank you page, so I just deleted it and it works beautifully. I had just followed the tutorials above (but when you're tired, sometimes you skip a step and have to go back...then things get messed up!)

    By the way, can you tell me how to have a link on the page that will allow the user download a file (i.e., word document). I'm sure it's easy, but I've fiddled with it this morning and it's not working.

    Thanks again!

  52. #52
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,317

    Default Re: How to upload a file using a form

    Just link it the normal way with the hyperlink button. The way it works is that they right lick on the link and then choose "save target as" to their computer. Thats it.

    Gald all is well with the form.

    Cheers-
    Andy
    PHP- is a blast!

  53. #53
    Join Date
    Oct 2007
    Location
    Arlington, TX
    Posts
    37

    Default Re: How to upload a file using a form

    I'm confused as to Notepad. Is that the HTML on the form or on the page?

  54. #54
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    No, it is a self standing file. You create it in Notepad and you upload it in your file using FTP.
    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!


  55. #55
    Join Date
    Jul 2006
    Posts
    7

    Default Don't allow bigger files

    Hello!

    I was trying to upload files using different scripts including BV one explained here but I have problems with size limit. I think the server don't allow to upload files bigger than 2MB...

    I changed the limit into the script to $upload_Size >1000000000.

    The upload form is installed on a Voda hosting, http://www.normal.ro/sbs/1.html

    Is anyone who knows how can I make server let me upload bigger files?

    Thanks,
    Sebastian

  56. #56
    Join Date
    Jul 2006
    Posts
    7

    Default Re: How to upload a file using a form

    ... and no error is displayed while a file is bigger than 2MB...

  57. #57
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Depending on the server settings, php will allow you to upload files up to 52 MB. Usually VH servers are set to 4.77 Mb.

    1000000000 that you have set, is 1 Gb !!!

    The script WILL give an error if the size is bigger than the set limit. Of course, if you have it set at 1 Gb, you will get no error message, though the file will not be uploaded if bigger than the server settings.
    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!


  58. #58
    Join Date
    Jul 2006
    Posts
    7

    Default Re: How to upload a file using a form

    Quote Originally Posted by navaldesign View Post
    Depending on the server settings, php will allow you to upload files up to 52 MB. Usually VH servers are set to 4.77 Mb.

    1000000000 that you have set, is 1 Gb !!!

    The script WILL give an error if the size is bigger than the set limit. Of course, if you have it set at 1 Gb, you will get no error message, though the file will not be uploaded if bigger than the server settings.
    I will need to upload files between 10 and 200MB (video files)... This VH server seems to be set to 2MB, as 1.9MB files are uploaded and 2.1MB are not... Do you have any idea what can I do to change the server limit?

  59. #59
    Join Date
    Jul 2006
    Posts
    7

    Talking Re: How to upload a file using a form

    I know that I changed the file limit to 1GB, I just wanted to be sure that I can upload any file I want until I get it fixed...

    Even the php 52 MB can be a reasonable limit... but 2MB is much to low...

  60. #60
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    You can NOT set the server limit, VH sets it. Usually only 4.77 is allowed. For larger files you need to use FTP or File Manager. Seems strange that 2.1 Mb is not uploaded, as said most VH servers are set to 4.77.
    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!


  61. #61
    Join Date
    Jul 2006
    Posts
    7

    Default Re: How to upload a file using a form

    Maybe VH lowered the limit to 2MB... However, it's very annoying, I'll try to talk with VH guys about that because I cannot teach my client how to use FTP to upload his videos on his website

    Anyway, thanks for your help!
    Sebastian

  62. #62
    Join Date
    Jan 2006
    Posts
    2

    Default Re: How to upload a file using a form

    Can some help, I tried all this and (the steps to allow visitors upload flies and images) but when I try my upload form and click submit it says this;

    Not Found

    The requested URL /uploadaction.php was not found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.




    why is this can someone help?

  63. #63
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Did you create the "uploadaction" page and publish it as php ?
    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!


  64. #64

    Default Re: How to upload a file using a form

    hi...i know this thread was from a long time ago and i'm hoping i can still get some help... i followed these instructions as best i could, then when i tried to test my form, it came up with a screen saying
    "Parse error: syntax error, unexpected $end in /home/ezioxokc/public_html/members/uploadaction.php on line 156"
    could someone please tell me what this means and what i've done wrong?
    this is gonna sound stupid but was i meant to delete the red writing? is that what i did wrong? or is it because i put it into a password protected directory inside the public_html folder?

    sorry to be such a pain!

    thanks, jess

    P.S. i have tried ABVFP but it doesn't seem to agree with me :( but now i appear to be having the same trouble with this way...
    Last edited by jessyh89; 12-12-2007 at 04:52 AM. Reason: more info

  65. #65
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    ABVFP is far more versatile than this script. And it will also mail you the attached files.

    However, we can't help you with this error, because this depends on your code. You must have missed a closing } somewhere.
    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!


  66. #66
    Join Date
    Apr 2008
    Posts
    2

    Default Re: How to upload a file using a form

    Hello, how can i make the script to filter the file extensions?

    Like i want that possible file types to upload are just .ZIP and .PNG

  67. #67
    Join Date
    Apr 2008
    Posts
    2

    Default Re: How to upload a file using a form

    Can someone help me please? Or can someone suggest me... How to protect the upload from hackers?

  68. #68
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    You need to use a code like

    $upload_Name1 = $_FILES[$file_key]['name'];
    $upload_Name = $prefix.str_replace(" ", "_", $upload_Name1);
    $upload_Size = ($_FILES[$file_key]['size']);
    $upload_Temp = ($_FILES[$file_key]['tmp_name']);
    $upload_Type = ($_FILES[$file_key]['type']);
    if($upload_Type != "image/gif" AND $upload_Type != "image/pjpeg" AND $upload_Type != "image/jpeg" AND $upload_Type != "image/png" AND $upload_Type != "image/tiff" AND $upload_Type != "image/bmp"){
    $error1 = "$file_key file type is '$upload_Type' which is not allowed! \n";
    // Add here a "include" command to include an error page
    }
    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!


  69. #69
    Join Date
    Mar 2008
    Posts
    21

    Default Re: How to upload a file using a form

    Hello Mr. Naval, can you please tell me what I did wrong here with code for uploading a file to my site. I use the same code that you presented, the only thing I change was the filesize from 1000000 (1mb) to 30000000 (30mb). Here is my problem: the code only takes file the have size from 7-8mb. But when I try to send a file with size 11mb the code did not show the error_page and it sent a blank email to me with a blank subject. And it kick off the thank_page to let the user know that their file was successfully sent. BUT NO FILE WAS UPLOADED. Can you tell me what I did wrong. Thanks.

    ====+++ uploaded code I used +++====

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

    // Validation for max file size
    if ($upload_Size>0)
    {
    if( $upload_Size > 30000000)
    {
    //delete file
    unlink($upload_Temp);
    header("Location: error.html");
    exit;
    }
    $uploadFile = "uploads/".$upload_Name ;
    @move_uploaded_file( $upload_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload_URL = "http://www.vietnam4christ.org/uploads/".$upload_Name ;
    }
    //Sending Email to form owner
    $mailto = "wesleyvinhvan@vietnam4christ.org";
    $mailsubj = "New Song Upload";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "File submitted:\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    $mailbody .= "upload: $upload_URL\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    // Autoresponder
    $mailto = $email;
    $mailsubj = "Song you Sumbitted";
    $mailhead = "From: Vietnam4christ.org\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    header("Location: thankyou_page.html");
    ?>

  70. #70
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Hi Wesley,
    First, i don't understand why you use this script. You have installed ABFP if i recall, and ABVFP can handle file uploads easire, automatically, so why do you use a separate script ?
    Second: with php there are server side limitations to the size of file you can upload. Usually it is set to 8 Mb on VH servers, in some cases to 12 Mb. A file bigger than that will cause ANY upload script to break.

    It is possible to increase the max file size, using a local php.ini file, for a maximum of 52 Mb which is the limit for php.
    However, creating a local php.ini file, can be somewhat tricky and it is not advisable that you do it unless you have some php experiense. Or it could mess your account.
    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!


  71. #71
    Join Date
    Aug 2008
    Location
    Parede - Portugal
    Posts
    2

    Question Re: How to upload a file using a form

    Hello i did everything was you explained but i still have an error when i try to upload files could you pls take a look in http://mobilarte-pt.cybercafedalinha.com/uploadform.php
    maybe i'm doing something wrong i don't know i review all several times and i can't see what is wrong.
    thank's in advance

  72. #72
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Don't use this script, it is an old one. Use he built in form processor, it can upload files.
    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!


  73. #73
    Join Date
    Aug 2008
    Location
    Parede - Portugal
    Posts
    2

    Smile Re: How to upload a file using a form

    Thank's Naval for your help is working great.
    Each day i feel that i made a great choice chosing Blue Voda.
    Thank You all for your help in the tutorials and forums .

    www.asuaempresaonline.com

  74. #74
    Join Date
    Apr 2007
    Posts
    14

    Default Re: How to upload a file using a form

    Dear Naval

    Re having the facility to upload photo files

    Have used the file wizard to do a form which comprises of 1 text field and 6 upload files and a submit button.
    When I test it it seems to upload photos ok, but when I check my mail box the resulting email mentions the text box and submit button but no mention of the upload files and no attached photos.

    What have I done wrong?

    Many thanks, Gordon
    Happy New Year

  75. #75
    Join Date
    Apr 2007
    Posts
    14

    Default Re: How to upload a file using a form

    It has just dawned on me that the problem might be that I'm using an AOL email address, would that be the case?

  76. #76
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    No, it has nothing to do with it. A link to the form please ?
    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!


  77. #77
    Join Date
    Apr 2007
    Posts
    14

    Default Re: How to upload a file using a form

    Hi Naval
    Thanks in anticipation, Gordon

    http://www.cheaperpages.com/partthree.php

  78. #78
    Join Date
    Apr 2007
    Posts
    14

    Default Re: How to upload a file using a form

    Hi Naval, Cracked it!

    Went to one of your previous threads and found the answer which was that I hadn't named the fields properly.

    Cheers, happy now!

  79. #79
    Join Date
    Dec 2008
    Posts
    19

    Talking Re: How to upload a file using a form

    Now right click your new created folder, and set the permissions to 777

    Thank you for all the info! I really needed this for my site The only thing I cannot figure out how to do is set the permissions to 777. I am in the Permissions for Upload file properties, but do not know exactly what to do from there. Thanks for your help!
    Have a great day!

    Amb

    iJotiT! @ www.myijot.com

  80. #80
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    if you are a VH customer, you don't need to use this script (this is old fashioned!)

    Simply use the Form Wizard and it's built in Form Processor, OR use ABVFP.

    They can both take care automatically of everything!

    If you are not a VH customer, use ABVFP which runs on any server that supports MySQL /php

    Last. if you insist on using this script, connect to your site with FTP, select the folder you use for the uploads, select Permissions (or properties, for some FTP softwares) and set them to 777.
    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!


  81. #81
    Join Date
    Dec 2008
    Posts
    19

    Default Re: How to upload a file using a form

    Okay, now I am totally lost..LOL.....I am a VH customer and very very new at forms. I did build the form with the wizard but it won't submit. As far as the permissions, just leave it alone because I used the wizard? Sorry to be a pain, I did not realize this was old (oops)
    Thanks for your help

  82. #82
    Join Date
    Jul 2010
    Location
    Alicante, Spain
    Posts
    60

    Question Re: How to upload a file using a form

    I'm not able to set correctly an upload form... Anyone can help me? I know that I have to write "submit data to a page (script)...." But where is says URL what am I supossed to write? I would like to create a new folder where all the videos would be submitted.

    Thx

  83. #83
    Join Date
    Jul 2010
    Location
    Alicante, Spain
    Posts
    60

    Default Re: How to upload a file using a form

    As you mention before... the above tutorial is outdated... is there a similar one where I can see step by step what I have to do to create an upload form?

    The video tutorial doesn't give much detail about upload forms and I can't find the right path to do this...

    Thx
    Newbie Lince

  84. #84
    Join Date
    Jul 2010
    Location
    Alicante, Spain
    Posts
    60

    Question Re: How to upload a file using a form

    I can upload the files properly to the uploads folder but I can't upload the videos... it actually does the action of uploading the video but then I cannot find the file anywhere in the server... it's a video of 3MB so it shouldn't be a big deal...

    Help... I need some help...

    Thx
    Newbie Lince

  85. #85
    Join Date
    Jul 2010
    Location
    Alicante, Spain
    Posts
    60

    Default Re: How to upload a file using a form

    The problem is that there is some kind of restriction to the file size limit around 2MB I'm not sure yet.

    But I can upload any file video or anything it it is smaller then 2 MB, but then if it's bigger
    I cannot upload it no matter what type of file it is.

    I have changed all the forms that a created on the ABVFP but that doesn't do anything...

    There must be some kind of restriction internally on the server .

    You've heard of a problem like this?

    Thx

  86. #86
    Join Date
    Jul 2011
    Posts
    1

    Default Re: How to upload a file using a form

    hello can any one tell me how to add uploading progress bar in my uploadform..when my user hit submit button..please tell

  87. #87
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    This requires Ajax coding that is quite complicated. For VERY advanced users only.
    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!


  88. #88
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    I want to have an "upload" feature on my site so that clients can upload photos for photo repair. Sometimes these files are large. . .up to 15 mgs. I have two questions:

    1. Is there a limit for size upload (I didn't see any way to set it or adjust)
    2. Where does the uploaded file go? I saw no feature to designate what file folder an uploaded file should be sent to.

    Thanks

  89. #89
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    The BV built in form processor can upload files. However, filesize is limited to (usually) 8 - 12 MBs. Support can increase this with a .htaccess file to 20 - 30 MBs.

    Files end up in the predefined "uploads" folder . You can set the destination folder in the built in form processor properties.
    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!


  90. #90
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    Thanks Nav. . .I'm at the properties box but I don't see how to designate the file folder. The properties box has a "general" 'styles" and "validate" tabs. . but I don't see where it asks for destination folder. thanks for your help.

  91. #91
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    Quote Originally Posted by McBuff View Post
    Thanks Nav. . .I'm at the properties box but I don't see how to designate the file folder. The properties box has a "general" 'styles" and "validate" tabs. . but I don't see where it asks for destination folder. thanks for your help.
    I'm wondering if anyone could give me a head's up on this issue:

    How does one designate the folder one wishes to have materials uploaded to on the "uploads" feature of a form. I have clients that want to upload photos for photo repair. I've set up a form with the "upload" utility but in setting it up, I can't find where one is supposed to specify the receiving folder. When something is then "uploaded". . I have no way of knowing if or where the file goes. What am I missing? Thanks

  92. #92
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    Well, here's the latest. I set up the form using the wizard, included input boxes for name, email, country and then the upload box and submit button. I, again, see no place to designate a file folder. . .but I publish it anyway. . . .I go to my site (www.wefixyourpix.com) and fill out the form. . attach a file and hit the submit button. I have no idea where that file is going. . .maybe Mars. . . .but. . .lo and behold. . it shows up AS A FILE ATTACHMENT ON THE EMAIL! Surprise!. . .well, okay. . maybe okay. . . .my gmail account is suppose to accept up to 25 mg file size. . should be more than enough. . .so maybe no problem. . .

    well. . problem. . .because I tried to send a 13 mg file. . .NO CAN DO. . . but. . I don't think it is a gmail limit but maybe a vodahost limit . .is that true?. . if so. . what's the limit? I really would appreciate a little insight on this so I can tell my clients what to expect. . .or maybe I should just drop the cockamamie thing and just tell them to yousendit.com me. . .

    I guess this upload feature is still buggy.. . Is there anyone out there that could tell me what the limit is on file transfer by email attachment?. . .7mg. . .12mg or 13mg . . (must be less than 13 because my 13mg file didn't make it.

    So, in conclusion. . .it seems the "file upload" is actually just attaching the file to the designated email address, not actually uploading to a folder in your site's files. Any insights will be appreciated (including telling me how much I'm off my rocker. . except. . .well . .I know that already!!)

  93. #93
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    Sorry about the confusion. It is my mistake actually, as I have been looking at the (in development) next version.

    True, files can only be sent as email attachments. If you need to store them on the server, you need to use the ABVFP.

    File size: it is usually limited to 8 MB. If you need to increase this size, create a file in Notepad as follows:

    #format
    php_value setting_name setting_value

    #example
    php_value post_max_size 32M
    php_value upload_max_filesize 32M
    php_value max_execution_time 60
    php_value memory_limit 64M

    Save it As, -> file type All Files, name it .htaccess and upload it on the server.
    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!


  94. #94
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    Quote Originally Posted by navaldesign View Post
    Sorry about the confusion. It is my mistake actually, as I have been looking at the (in development) next version.

    True, files can only be sent as email attachments. If you need to store them on the server, you need to use the ABVFP.

    File size: it is usually limited to 8 MB. If you need to increase this size, create a file in Notepad as follows:

    #format
    php_value setting_name setting_value

    #example
    php_value post_max_size 32M
    php_value upload_max_filesize 32M
    php_value max_execution_time 60
    php_value memory_limit 64M

    Save it As, -> file type All Files, name it .htaccess and upload it on the server.
    Hey thanks, Nav. ..bit by bit. . .this thing is getting there. I don't necessarily need the files on the server. . .if it comes via attachment that is fine. One question about your answer here. When you say "file size is usually limited to 8 MB" is that referring to the ABVFP solution only or are you saying that 8mg is the limit from Voda for email attachments (or both)? If 8mg files can get to me via email attachments. ..that probably will work in that I'm only going to be receiving photo files from clients for repair. I can leave instructions on the form page if their file is larger than (whatever the limit is).

    If it turns out that the email attachment limit is too small, I will then check out your recommendation for using the ABVFP (which I have no idea what that is. . however I've seen several posts regarding that and I will refer to those for instructions first and get back to you if I get stumped.)

    Thanks again, Nav. . .I don't post that much. . but I read your instructions to others all the time. .. you've helped me alot without knowing it. . so thanks for that as well!

  95. #95
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,080

    Default Re: How to upload a file using a form

    When a file is uploaded through a form, the file size is limited by the server settings. This is why I provided also the method to increase this limit.

    The email attachement limit instead depends mainly on your ISP (your internet connection provider)

    ABVFP is an alternative form processor, which allows storing the files on the server instead of attaching them in the mail.

    Related thread: http://www.vodahost.com/vodatalk/for...essor-2-a.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!


  96. #96
    Join Date
    Aug 2006
    Posts
    87

    Default Re: How to upload a file using a form

    Quote Originally Posted by navaldesign View Post
    When a file is uploaded through a form, the file size is limited by the server settings. This is why I provided also the method to increase this limit.

    The email attachement limit instead depends mainly on your ISP (your internet connection provider)

    ABVFP is an alternative form processor, which allows storing the files on the server instead of attaching them in the mail.

    Related thread: http://www.vodahost.com/vodatalk/for...essor-2-a.html
    I installed the ABVFP and after a few initial hic-cups. . .everything seems to be working. . . files are uploading and everything looks good . . .Great Nav. . thanks so much.

  97. #97
    Join Date
    Oct 2012
    Posts
    1

    Default Re: How to upload a file using a form

    First I will explain why I am interested in this idea. I have a website where I sell photo editing services. I need a solution that allows a customer to choose one or more services to be applied to each photo. They may want work done on more than one photo. Then they would pay via paypal before being sent to the upload page.

    I have a couple of questions. The first is just verification as I don't see why it wouldn't work. Is it possible to send a customer to paypal, then set a redirect back to the upload page? Is it possible to set the page so it can only be accesses after a redirect from paypal? This would prevent someone from saving a link or stumbling across the page and uploading pictures without paying.

    After reviewing all the posts I see this is an old post and at the time you were working on a new version. Please direct me to a more recent tutorial if one exists that might solve my problems.

    Thanks

  98. #98
    Join Date
    Mar 2006
    Posts
    14,683

    Default Re: How to upload a file using a form

    Re-directing from PayPal to a particular page is a normal function of the Paypal configuration. To make sure your "upload" page is hidden from general traffic, simply do not provide a link to it anywhere on the site itself, and be sure to include it in particular as one of your specified "nofollow" rules in your 'robots.txt' file which should be repeated in your 'sitemap.xml' file ... both of which your site should have in place once it is completed.

    > The robots.txt file
    . VodaWebs....Luxury Group
    * Success Is Potential Realized *

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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