PDA

View Full Version : video/image upload script?



lost-angel
05-20-2006, 07:22 AM
I have assigned the following values to my form:
- Action: upload.php
- Method: POST
- EncodingType: multipart/form-data
I have tried for the last 8 hours to use scripts from various threads and they all fail... I am sure that I am missing a critical step. Is there anyone who can walk me thru to the next step... the form is here: www.lost-angelz.com/submit.html (http://www.lost-angelz.com/submit.html) I assume the next steps= create an upload folder in the public direct, create an upload.php page on the same public directory. what is the magical php script to make my form work?

navaldesign
05-20-2006, 09:01 AM
<?php

// Receiving variables
@$userfile_Name = $_FILES['userfile']['name'];
@$userfile_Size = $_FILES['userfile']['size'];
@$userfile_Temp = $_FILES['userfile']['tmp_name'];
@$userfile_Mime_Type = $_FILES['userfile']['type'];
@$Name = addslashes($_POST['Name']);
@$E-mail = addslashes($_POST['E-mail']);
@$comment = addslashes($_POST['comment']);
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if ($userfile_Size>0)
{
// Validation
if( $userfile_Size == 0)
{
header("Location: errorpage.html");
exit;
}
if( $userfile_Size >50000)
{
//delete file
unlink($userfile_Temp);
header("Location: errorpage.html");
exit;
}
$uploadFile = "upload/".$userfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $userfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$userfile_URL = "http://www.lost-angelz.com/upload/".$userfile_Name ;
}

//Sending Email to form owner
$pfw_header = "From: $E-mail\n"
. "Reply-To: $E-mail\n";
$pfw_subject = "New File Upload";
$pfw_email_to = "youremail@yourdomain.com";
$pfw_message = "There is a new file uploaded.\n"
. "-----------------------------------\n"
. "File Link: $userfile_URL\n"
. "Name: $Name\n"
. "E-mail: $E-mail\n"
. "Comment: $comment\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyoupage.html");
?>


Create a folder in your public_html directory, call it "upload" and give it permissions 777.
Copy the code, paste it in notepad, change youremail@yourdomain.com with the real email in your Vodahost account. If you wish the file size limit different than the 50000 bytes i have put in the script, just change it. Go to Save as, choose File Type: All files, and save it as "upload.php" Upload it in your public_html folder.

Create two simple pages in BV, one called "errorpage" (for letting them know that the file is bigger than the allowed limit) and the second one "thankyoupage". Publish them. You are done.
Please note that in the email you will have the file link, so just click on it to openit in your browser. If the file name has blank spaces, then the link will be broken, and you will need to copy the whiole link and paste it in your browser's address bar. If the file is of a type that can't be opened in your browser, just use Blue FTP to download it from your site to your computer and then open it using the appropriate software.

lost-angel
05-20-2006, 04:28 PM
I copied and pasted the code listed below. I followed all instructions as far as creating folder and php page, thanx and error... I tested the form out, I did a test upload and it seemed to be working but instead of getting a thanks page or an error page i got this:

Parse error: syntax error, unexpected '=' in /home/myusername/public_html/upload.php on line 9

I replaced the correct directory path user name with "myusername" just to protect the account... below is the code I used, Did I mess up with an extra '=' or something?

<?php
// Receiving variables
@$userfile_Name = $_FILES['userfile']['name'];
@$userfile_Size = $_FILES['userfile']['size'];
@$userfile_Temp = $_FILES['userfile']['tmp_name'];
@$userfile_Mime_Type = $_FILES['userfile']['type'];
@$Name = addslashes($_POST['Name']);
@$E-mail = addslashes($_POST['E-mail']);
@$comment = addslashes($_POST['comment']);
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if ($userfile_Size>0)
{
// Validation
if( $userfile_Size == 0)
{
header("Location: errorpage.html");
exit;
}
if( $userfile_Size >100000)
{
//delete file
unlink($userfile_Temp);
header("Location: errorpage.html");
exit;
}
$uploadFile = "upload/".$userfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $userfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$userfile_URL = "<A href="http://www.lost-angelz.com/upload/".$userfile_Name">http://www.lost-angelz.com/upload/".$userfile_Name ;
}
//Sending Email to form owner
$pfw_header = "From: $E-mail\n"
. "Reply-To: $E-mail\n";
$pfw_subject = "New File Upload";
$pfw_email_to = "mye-mail@lost-angelz.com (mye-mail@lost-angelz.com)";
$pfw_message = "There is a new file uploaded.\n"
. "-----------------------------------\n"
. "File Link: $userfile_URL\n"
. "Name: $Name\n"
. "E-mail: $E-mail\n"
. "Comment: $comment\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyoupage.html");
?>

navaldesign
05-20-2006, 08:21 PM
No, the problem seems to be (sorry i didn't see it before) the email field. Take the "-" off both your form and your script. Name the field "Email", and change accordingly all the necessary lines in the script, turning "E-mail" to "Email"

lost-angel
05-20-2006, 08:55 PM
Navel Design, thanks... I finally got the Thankyou page after testing, so thanks.. funny how 1 little character can throw off the entire form process. EVERYTHING WORKS,thanx

navaldesign
05-20-2006, 09:10 PM
You are welcome

lost-angel
05-20-2006, 09:20 PM
umm, the script works but in the email I am missing the file link... I even went into the file manager via cpanel x to search... and the folder has no files even though the email says I have a new file upload... here is a copy and paste from the test upload:

There is a new file uploaded.
-----------------------------------
File Link:
Name: Daleon
Email: scar_mega@lost-angelz.com (scar_mega@lost-angelz.com)
Comment: my kicks

navaldesign
05-20-2006, 09:34 PM
Sorry, one more mistake on my side. Change the $upload1_Size (blue colour) to $userfile_Size . Copying and pasting from my own scripts sometimes make me forget to correct the variable names. Sorry again.

lost-angel
05-20-2006, 10:23 PM
Yep, that worked.... but ummm ran into another road block. I got this message when I clicked the link in the e-mail:


There is a new file uploaded.
-----------------------------------
File Link: http://www.lost-angelz.com/upload/airjordaniv.jpg (http://www.lost-angelz.com/upload/airjordaniv.jpg)
Name: Daleon
Email: scar_mega@lost-angelz.com (https://70.86.134.194:2096/3rdparty/squirrelmail/src/compose.php?send_to=scar_mega%40lost-angelz.com)
Comment: kicks


the above file link lead to this message:
Forbidden

You don't have permission to access /upload/airjordaniv.jpg on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

also in cpanelx file manager:

Show File Contents (https://70.86.134.194:2083/frontend/x/files/showfile.html?dir=/home/tgxddodp/public_html/upload&file=airjordaniv.jpg) <--- this actually opens the file that the link says is forbidden
Delete File (https://70.86.134.194:2083/frontend/x/files/tra****.html?dir=/home/tgxddodp/public_html/upload&file=airjordaniv.jpg)
Edit File (https://70.86.134.194:2083/frontend/x/files/editit.html?dir=/home/tgxddodp/public_html/upload&file=airjordaniv.jpg)
Change Permissions (https://70.86.134.194:2083/frontend/x/files/perm.html?dir=/home/tgxddodp/public_html/upload&file=airjordaniv.jpg)
Rename File (https://70.86.134.194:2083/frontend/x/files/rename.html?dir=/home/tgxddodp/public_html/upload&file=airjordaniv.jpg)
Copy File (https://70.86.134.194:2083/frontend/x/files/fileop.html?opdir=/home/tgxddodp/public_html/upload&opfile=airjordaniv.jpg&fileop=copy)
Move File (https://70.86.134.194:2083/frontend/x/files/fileop.html?opdir=/home/tgxddodp/public_html/upload&opfile=airjordaniv.jpg&fileop=move)

File Url: http://www.lost-angelz.com/upload/airjordaniv.jpg (http://www.lost-angelz.com/upload/airjordaniv.jpg) <-- leads to forbidden message

navaldesign
05-21-2006, 06:24 AM
Click on http://www.lost-angelz.com/upload (http://www.lost-angelz.com/upload) then on airjordaniv.jpg I can see, and i can download the ***** pic, which means that the file permissions are ok. Check the permissions of your "upload" folder.

lost-angel
05-21-2006, 05:21 PM
ok... that works, thanks

navaldesign
05-21-2006, 05:28 PM
So everything ok ?

lost-angel
05-21-2006, 11:59 PM
It appears so... I have tested the new upload links... sometimes they connect.. sometimes they lead to the forbidden message so what i do when I get the forbidden message is break the link down to: http:lost-angelz.com/upload which takes me to a root directory for the upload folder.. i just click the relating upload file ... its a longer route to get the upload rather than just clicking the link in the e-mails but i can live with it... but like I said, sometimes the link in the e-mail actually opens the file but when i get the forbidden message I just break the link down to the root directory of the folder... So yes.. everything is good..thanks for the script

navaldesign
05-22-2006, 05:51 AM
You are welcome.

zangoo
06-03-2006, 04:23 AM
I was trying out this upload script. Everytime I run it I only get the Thank You Page and an email with no infofor link, file etc. Any help will do.

navaldesign
06-03-2006, 05:58 PM
I was trying out this upload script. Everytime I run it I only get the Thank You Page and an email with no infofor link, file etc. Any help will do.

Please upload your php script.

bannacom
06-06-2006, 07:22 PM
i used above mentioned instruction and adjusted it for my needs. everything works great except last line "comment". i dont know where is the problem, there is no comment text in email. My form: http://www.bannerclickmania.com/form1.php



<?php

// Receiving variables
@$userfile_Name = $_FILES['userfile']['name'];
@$userfile_Size = $_FILES['userfile']['size'];
@$userfile_Temp = $_FILES['userfile']['tmp_name'];
@$userfile_Mime_Type = $_FILES['userfile']['type'];
@$Name = addslashes($_POST['Name']);
@$Email = addslashes($_POST['Email']);
@$comment = addslashes($_POST['comment']);
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if ($userfile_Size>0)
{
// Validation
if( $userfile_Size == 0)
{
header("Location: errorpage.html");
exit;
}
if( $userfile_Size >5000000)
{
//delete file
unlink($userfile_Temp);
header("Location: errorpage.html");
exit;
}
$uploadFile = "upload/".$userfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $userfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$userfile_URL = "http://www.bannerclickmania.com/upload/".$userfile_Name ;
}

//Sending Email to form owner
$pfw_header = "From: $Email\n"
. "Reply-To: $Email\n";
$pfw_subject = "New File Upload";
$pfw_email_to = "addbanner@bannerclickmania.com";
$pfw_message = "There is a new file uploaded.\n"
. "-----------------------------------\n"
. "File Link: $userfile_URL\n"
. "Name: $name\n"
. "Email: $Email\n"
. "Webpage: $webpage\n"
. "Numbercell: $numbercell\n"
. "Micetext: $micetext\n"
. "Password: $password\n"
. "Comment: $comment\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyoupage.html");
?>

bannacom
06-06-2006, 07:50 PM
I forgot to ask. How to add my option butons to the code?

navaldesign
06-06-2006, 09:02 PM
The two radio buttons should belong to the same group. I don't know why you don't receive the comment textarea content. It looks ok.

VodaHost
06-09-2006, 08:36 PM
click the below...

http://www.vodahost.com/vodatalk/forms/8220-form-maker-pro.html

lost-angel
10-19-2006, 10:50 PM
Was getting alot of test submissions... blank forms sumitted. This webpage (video upload) has been removed from http://www.lost-angelz.com and replaced with a standard contact form, The script supplied by naval design does work. Page was removed from website only because uploading files was no longer needed. If you do use the script you may want to ad a validator code string to stop blank submissions.

rameshdgr8
07-03-2007, 06:15 AM
<?php

// Receiving variables
@$userfile_Name = $_FILES['userfile']['name'];
@$userfile_Size = $_FILES['userfile']['size'];
@$userfile_Temp = $_FILES['userfile']['tmp_name'];
@$userfile_Mime_Type = $_FILES['userfile']['type'];
@$Name = addslashes($_POST['Name']);
@$E-mail = addslashes($_POST['E-mail']);
@$comment = addslashes($_POST['comment']);
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if ($userfile_Size>0)
{
// Validation
if( $userfile_Size == 0)
{
header("Location: errorpage.html");
exit;
}
if( $userfile_Size >50000)
{
//delete file
unlink($userfile_Temp);
header("Location: errorpage.html");
exit;
}
$uploadFile = "upload/".$userfile_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $userfile_Temp , $uploadFile);
chmod($uploadFile, 0644);
$userfile_URL = "http://www.lost-angelz.com/upload/".$userfile_Name ;
}

//Sending Email to form owner
$pfw_header = "From: $E-mail\n"
. "Reply-To: $E-mail\n";
$pfw_subject = "New File Upload";
$pfw_email_to = "youremail@yourdomain.com";
$pfw_message = "There is a new file uploaded.\n"
. "-----------------------------------\n"
. "File Link: $userfile_URL\n"
. "Name: $Name\n"
. "E-mail: $E-mail\n"
. "Comment: $comment\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyoupage.html");
?>


Create a folder in your public_html directory, call it "upload" and give it permissions 777.
Copy the code, paste it in notepad, change youremail@yourdomain.com with the real email in your Vodahost account. If you wish the file size limit different than the 50000 bytes i have put in the script, just change it. Go to Save as, choose File Type: All files, and save it as "upload.php" Upload it in your public_html folder.

Create two simple pages in BV, one called "errorpage" (for letting them know that the file is bigger than the allowed limit) and the second one "thankyoupage". Publish them. You are done.
Please note that in the email you will have the file link, so just click on it to openit in your browser. If the file name has blank spaces, then the link will be broken, and you will need to copy the whiole link and paste it in your browser's address bar. If the file is of a type that can't be opened in your browser, just use Blue FTP to download it from your site to your computer and then open it using the appropriate software.

Hi Dude,

i am working on a very big project and i need this functionality.
User should be able to upload videos in the site. I need the complete code for the form as well as script.
can you please do this favour for me

Thanks
Ramesh

navaldesign
07-03-2007, 06:23 AM
Creating he code for the form as wel as the script goes beyond this forum limits. However, i suggest that you create your form in BV, and then download and install Advanced BlueVoda Form Processor (http://www.vodahost.com/vodatalk/forms/12794-advanced-bluevoda-form-processor.html) which will take care of the submission part and will also deliver the files on your desktop as attached files in your email.

rameshdgr8
07-03-2007, 06:26 AM
thnx a lot dude. will try the way you suggested and will ping you when if i fall into problem.