Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > BlueVoda Website Builder Forums > Forms

Notices

Forms Discussion and help related to designing and implementing forms in the BlueVoda Website Builder.

Reply
 
LinkBack Thread Tools
  #1  
Old 05-13-2006, 03:10 PM
VodaHost's Avatar
General & Forum Administrator
 
Join Date: Mar 2005
Location: Wilmington, Delaware USA
Posts: 8,503
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.

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


January 2007update: Advanced BlueVoda Form Processor will now also email you as attachments, the uploaded files.


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:

Quote:
<?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
07092887580 / United Kingdom

Military Ranking System Explained


Click Here to take the royal VodaHost Tour
Click Here for the VodaHost Help Centre & Tutorials
Got a question? - Try a forum search! Available at the top of every page!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 05-13-2006, 03:14 PM
davidundalicia's Avatar
Lieutenant General
 
Join Date: Mar 2006
Location: Mallorca, Spain
Posts: 3,951
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 *****..
__________________
Have fun
Regards
David

FREE Membership Login Scripts:
Meta Tags Analyzer
Mallorca Holiday Home
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 05-13-2006, 03:34 PM
Girlonthehill's Avatar
General
 
Join Date: Oct 2005
Location: England, UK
Posts: 4,239
Thumbs up Re: How to upload a file using a form

Nice one, Mon General!!
__________________
The moment one definitely commits oneself, then providence moves too. All sorts of things occur to help one that would never otherwise have occurred. A whole stream of events issues from the decisions, raising in one’s favor all manner of unforeseen incidents and meetings and material assistance which no man could have dreamed would have come his way. Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now. (William Hutchinson Murray)

Last edited by VodaHost; 05-13-2006 at 04:01 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 07-10-2006, 10:23 PM
Private
 
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 08-01-2006, 01:11 PM
Staff Sergeant
 
Join Date: Jun 2005
Location: Wirral, England
Posts: 48
Send a message via MSN to scousepete79
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 08-01-2006, 06:18 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,033
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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 08-04-2006, 10:41 PM
Private
 
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 08-05-2006, 08:07 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,033
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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old 08-05-2006, 11:21 AM
Sergeant
 
Join Date: Nov 2005
Location: Surrey, UK
Posts: 33
Default Re: How to upload a file using a form

*****,

yet another great resource for us to use.

thanks
Stevea
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old 08-21-2006, 11:44 AM
Sergeant First Class
 
Join Date: Mar 2006
Location: UK
Posts: 52
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old 08-24-2006, 02:08 PM
Corporal
 
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old 08-24-2006, 02:19 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,033
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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old 08-25-2006, 01:28 AM
Corporal
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old 09-01-2006, 10:57 AM
Private
 
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old 09-03-2006, 04:10 PM
Corporal
 
Join Date: Aug 2006
Posts: 13
Default Re: How to upload a file using a form

lol ty bud named folder upload instead of uploads. it works great now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old 09-04-2006, 12:41 AM
davidundalicia's Avatar
Lieutenant General
 
Join Date: Mar 2006
Location: Mallorca, Spain
Posts: 3,951
Default 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

FREE Membership Login Scripts:
Meta Tags Analyzer
Mallorca Holiday Home
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old 09-04-2006, 10:09 AM
navaldesign's Avatar