PDA

View Full Version : Script help!



lionegg
03-22-2006, 11:24 AM
Hi,
can anyone help with a script for my form. The form can be found at www.lionegg.co.uk/temp.html (http://www.lionegg.co.uk/temp.html) its only a small form, all fields are required and i need the image (with size limit) to be recieved as an attachment with the rest of the information when it is sent. I understand it currently goes to a default folder but this would not be good for me (and when previously testing i couldnt even find this folder!). Thank-you in advance.

Darren

navaldesign
03-22-2006, 12:05 PM
1. Your field are all named T1 which is the default name BV gives them
2. 3 Kb is only enough for small thumbnails, not for images.
3. Receiving the file as an attachment could be a little difficult. If it gets uploaded on the server, and you have the link in the email, you can simply click the link, to open the imege in IE, and then save it on your computer with the right click "Save Image as.." feature, or simply download it with BlueFTP.
4. You couldn't find the upload folder because this is a folder YOU MUST CREATE. You create it, and then the script uploads the pics in that folder.

As for the script it self, if this solution is good for you, i can create it for you. However, a little search in the web could also help you find the solution to specific problems you might have.

lionegg
03-22-2006, 02:05 PM
Hi,

I had just created the form quickly as an example, i forgot about renaming the fields ( i think that demonstartes how much help i need lol). I am only really in need of small thumbnails, so i thought 3kb would be suitable, however its still in debate.
The link to the image in the email sounds like a grand idea, and would have the same goal.

I found form processors on hotscripts.com are these a worth while solution?

navaldesign
03-22-2006, 02:22 PM
Some of them are, but most of them are hard to configure and they cost. Prepare your form, create a thankyou and two error pages (for empty field and for non truelike email) publish the pages and let me know the urls and your domain. I'll give you the script.

nick1346
03-22-2006, 02:30 PM
Hi Darren and Naval Design,

This sounds like you have the same problem as myself Darren. Will you put the script on here naval design so that i can have a look?

Thanks

Nick

lionegg
03-22-2006, 07:33 PM
Hi Navaldesign,

The form page can be found at http://www.lionegg.co.uk/upload.html
The field error page at http://www.lionegg.co.uk/upload_errortype1.html
Non true email page at http://www.lionegg.co.uk/upload_errortype2.html
And thankyou page at http://www.lionegg.co.uk/upload_thankyou.html

Thank you so much for this, very much apprciated.

navaldesign
03-22-2006, 08:25 PM
Ok, i'll check your form and send you the script tomorrow.

lionegg
03-22-2006, 08:39 PM
Thanks thats great!

navaldesign
03-23-2006, 03:37 PM
Ok, this is your script:
<?php
// Receiving variables
@$CONTACT_EMAIL_ADRESS = addslashes($_POST['CONTACT_EMAIL_ADRESS']);
@$COMMENT = addslashes($_POST['COMMENT']);
@$TITTLE = addslashes($_POST['TITTLE']);
@$IMAGE_Name = $_FILES['IMAGE']['name'];
@$IMAGE_Size = $_FILES['IMAGE']['size'];
@$IMAGE_Temp = $_FILES['IMAGE']['tmp_name'];
@$IMAGE_Mime_Type = $_FILES['IMAGE']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}

// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $CONTACT_EMAIL_ADRESS))
{
header("Location: upload_errortype2.html");
exit;
}
if (strlen($CONTACT_EMAIL_ADRESS) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($COMMENT) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($TITTLE) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if ($IMAGE_Size>0)
{
if( $IMAGE_Size >50000)
{
//delete file
unlink($IMAGE_Temp);
header("Location: upload_errortype3.html");
exit;
}


if( $IMAGE_Mime_Type != "image/gif" AND $IMAGE_Mime_Type != "image/jpeg" AND $IMAGE_Mime_Type != "image/png" AND $IMAGE_Mime_Type != "image/tiff" )
{
unlink($IMAGE_Temp);
header("Location: upload_errortype4.html");
exit;
}


$uploadFile = "upload/".$IMAGE_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $IMAGE_Temp , $uploadFile);
chmod($uploadFile, 0644);
$IMAGE_URL = "http://www.yourdomain.co.uk/upload/".$IMAGE_Name ;
}
// Find Server date and Time
$date = date("l jS F Y, g:i A");

// Find Browser and IPaddress
$browser =$_SERVER['HTTP_USER_AGENT'];

$ip = $_SERVER['REMOTE_ADDR'];

//Sending Email to form owner
$pfw_header = "From: $CONTACT_EMAIL_ADRESS\n"
. "Reply-To: $CONTACT_EMAIL_ADRESS\n";
$pfw_subject = "New Picture Upload";
$pfw_email_to = "youremail@yourdomain.co.uk";
$pfw_message = "A new Picture has been uploaded\n"
. "-----------------------------------------\n"
. "\n"
. "\n"
. "CONTACT_EMAIL_ADRESS: $CONTACT_EMAIL_ADRESS\n"
. "COMMENT: $COMMENT\n"
. "TITTLE: $TITTLE\n"
. "IMAGE: $IMAGE_URL\n"
. " \n"
. "Date of upload : $date\n"
. "Browser : $browser\n"
. "IP address : $ip\n";


*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyou_page.html");
?>


Please follow these steps:
1. Copy and paste this code in Notepad. Change your email address, with one of your vodahost account emails. Go to "Save As", choose File Type "All Files", and save it as "upload1.php" . Upload it on the server.
2. Create a folder in your public_html, called "upload". This is where all the images will be stored. Set permissions for this folder in 777
3. Create two more error pages: "upload_errortype3.html" and "upload_errortype4.html" the first for File size exceeding 50 kb (this is the limit i have put, you may change it to be 3 - 5 or what you want kb (The size is in Bytes) and the second for wrong file type (i have put jpeg, png, tiff and gif as acceptable types)

Test the script and let me know.

nick1346
03-24-2006, 11:20 AM
Hi Naval Design

Hope you don't mind but I'm trying to use this script myself as I have the same problem.
I have followed your instructions and after attempting to upload an image got the message:
Parse error: parse error, unexpected T_STRING in /home/dznxeig/public_html/upload1.php on line 69

My sample form is found at http://www.yourlocal.org.uk/upload.html

Thanks this has been a huge help.

Nick

navaldesign
03-24-2006, 12:02 PM
Please try now. There has been a problem with the text editor, resulting in translating a link in a A <href....> where it shouldn't be in line 60. It should work ok now.

nick1346
03-24-2006, 03:08 PM
Hi

I've altered the upoad1.php and thats has got rid of the error in line 69 message, but now I only get the errortype2 page coming up. I think that I may of set something up incorrectly. On the form properties I take it that I set the action to upload1.php, method=post and encoding blank or am I most probably wrong. When I created the download folder I put it in the public_html file not the public_ftp and likewise with the upload1.php. Any help would be a big help.

Many Thanks

Nick

navaldesign
03-24-2006, 03:24 PM
Hi

I've altered the upoad1.php and thats has got rid of the error in line 69 message, but now I only get the errortype2 page coming up. I think that I may of set something up incorrectly. On the form properties I take it that I set the action to upload1.php, method=post and encoding blank or am I most probably wrong. When I created the download folder I put it in the public_html file not the public_ftp and likewise with the upload1.php. Any help would be a big help.

Many Thanks

Nick

Encoding=multipart / form data and try. Please also note that this script has been prepared for lionegg. This means that the field names are suited to his form. If one of your fileld names is even slightly different, the script considers that field to be blank, and gives you the errortype2

nick1346
03-24-2006, 05:10 PM
Hi Navaldesign,

Excellent almost there, I changed the form properties as you said and yes I had one to many spaces in my email field name! Now all the pages work but it still does not send the photo to my upload file, any ideas?

Thanks again

Nick

navaldesign
03-24-2006, 05:26 PM
Hi Navaldesign,

Excellent almost there, I changed the form properties as you said and yes I had one to many spaces in my email field name! Now all the pages work but it still does not send the photo to my upload file, any ideas?

Thanks again

Nick

Please upload me here a copy of the email you get

nick1346
03-24-2006, 05:32 PM
Hope this helps:


There is a new picture uploaded.
Here is the info and the Link
----------------------------------------
TITTLE: nn
COMMENT: mnmnm
CONTACT_EMAIL_ADRESS: xym@hjhk.mk
IMAGE:

Date of upload : Friday 24th March 2006, 11:24 AM
Browser : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
IP address : 84.65.1.91

navaldesign
03-24-2006, 05:39 PM
Please go in here (http://www.navaldesign.info/feedback13.html) and provide me your vodahost account email

nick1346
03-24-2006, 05:55 PM
Hi

Do you mean the email I recieved when I signed up for my account with all the server details etc?

Thanks

Nick

navaldesign
03-24-2006, 06:57 PM
No i mean the email address you have put in your script

nick1346
03-24-2006, 07:59 PM
Ok, got a bit confused! Spring is in the air. I'll send it now

navaldesign
03-25-2006, 05:59 AM
I have checked the script and corrected an error. But it is quite probable that the problem was that the "upload" folder permissions have to be set at "777" and also you should probably re-make your "upload" field from scratch, naming it again "IMAGE" and MAKING SURE THAT IT IS WITHIN THE FORM AREA". Otherwise widen the form area a bit to make it fit.

nick1346
03-25-2006, 12:02 PM
Hi
I Have uploaded the corrrected script, set the permissions to 777 and redone the iamge field just to make sure. Unfortunately it's now giving me the error
Parse error: parse error, unexpected T_STRING in /home/dznxeig/public_html/upload1.php on line 66
I know this must be taking up a lot of time, it's much appreiciated
Nick

navaldesign
03-25-2006, 04:03 PM
Please try it again now, starting again from copy/paste. I don't know why, but the editor changes the line of the Image Url, giving the error. If this is not ok now, please let me know so i can send you the file as email attachment.

nick1346
03-26-2006, 04:23 PM
Hi
I have done the copy and paste and that did it exactly this time, I've set the permissions to 777 and double checked all the field names etc. When a tried to send a picture it gave me a page not found. I've had a look and can't see whats wrong, any thoughts?

Cheers

navaldesign
03-26-2006, 04:38 PM
Hi
I have done the copy and paste and that did it exactly this time, I've set the permissions to 777 and double checked all the field names etc. When a tried to send a picture it gave me a page not found. I've had a look and can't see whats wrong, any thoughts?

Cheers

Check the name under which you have saved the script. The 404 error is telling you that the script page is not there. And excactly at which point did you get that error message? Please note that in some cases the file type controll doesn't work fine if the file info is not embedded well in the file itself, so i personally prefer not to check the file type. In this case you should take off the script the lines in BLUE. This might be causing you the problem.

lionegg
03-26-2006, 07:08 PM
Hi Navaldesign and Nick,
I have been very busy and only just had the chance to try out the script. I've followed all the posts to date. From the first script i received an email but no link to the image. This was probably because i did not have the folder set to 777. But now i am using the most recent script (minus the blue txt) and am also experencing the same problems as Nick. Also last night when i was trying to get it to work i noticed that when i went to upload the script the previous script was not in my public_html file. I have no idea what would cause this to happen but it could be the reason why when submitting the information it is going to the 404 page?!

navaldesign
03-26-2006, 07:25 PM
I emailed nick privately. Seems like there is a prblem with the forum text editor in conjunction to the code it self: so i had to manually correct it. Test the form at http://www.navaldesign.info/nick1346.html (http://www.navaldesign.info/nick1346.html) then contact me so i will email you the script.

lionegg
03-26-2006, 08:58 PM
I have sent an email to your website address, thanks

navaldesign
03-26-2006, 09:21 PM
I tried to email you back but got a bad address error. I didn't get an image, did you send me one?

lionegg
03-26-2006, 09:54 PM
Ok i will try again now, and supply multiple address, just incase

nick1346
03-27-2006, 01:57 PM
Hi Gents

It works! Thanks for all your help and patience navaldesign without this I would be up the creek without a paddle.
The last issue I had was in fact easily sorted the name of the thankyou page just needed to be changed, bearing that in mind the above code works perfectly.
Thanks again

nick

Girlonthehill
04-18-2006, 05:21 PM
Ok, this is your script:
<?php
// Receiving variables
@$CONTACT_EMAIL_ADRESS = addslashes($_POST['CONTACT_EMAIL_ADRESS']);
@$COMMENT = addslashes($_POST['COMMENT']);
@$TITTLE = addslashes($_POST['TITTLE']);
@$IMAGE_Name = $_FILES['IMAGE']['name'];
@$IMAGE_Size = $_FILES['IMAGE']['size'];
@$IMAGE_Temp = $_FILES['IMAGE']['tmp_name'];
@$IMAGE_Mime_Type = $_FILES['IMAGE']['type'];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}

// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $CONTACT_EMAIL_ADRESS))
{
header("Location: upload_errortype2.html");
exit;
}
if (strlen($CONTACT_EMAIL_ADRESS) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($COMMENT) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if (strlen($TITTLE) == 0 )
{
header("Location: upload_errortype1.html");
exit;
}
if ($IMAGE_Size>0)
{
if( $IMAGE_Size >50000)
{
//delete file
unlink($IMAGE_Temp);
header("Location: upload_errortype3.html");
exit;
}


if( $IMAGE_Mime_Type != "image/gif" AND $IMAGE_Mime_Type != "image/jpeg" AND $IMAGE_Mime_Type != "image/png" AND $IMAGE_Mime_Type != "image/tiff" )
{
unlink($IMAGE_Temp);
header("Location: upload_errortype4.html");
exit;
}


$uploadFile = "upload/".$IMAGE_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $IMAGE_Temp , $uploadFile);
chmod($uploadFile, 0644);
$IMAGE_URL = "http://www.yourdomain.co.uk/upload/".$IMAGE_Name ;
}
// Find Server date and Time
$date = date("l jS F Y, g:i A");

// Find Browser and IPaddress
$browser =$_SERVER['HTTP_USER_AGENT'];

$ip = $_SERVER['REMOTE_ADDR'];

//Sending Email to form owner
$pfw_header = "From: $CONTACT_EMAIL_ADRESS\n"
. "Reply-To: $CONTACT_EMAIL_ADRESS\n";
$pfw_subject = "New Picture Upload";
$pfw_email_to = "youremail@yourdomain.co.uk";
$pfw_message = "A new Picture has been uploaded\n"
. "-----------------------------------------\n"
. "\n"
. "\n"
. "CONTACT_EMAIL_ADRESS: $CONTACT_EMAIL_ADRESS\n"
. "COMMENT: $COMMENT\n"
. "TITTLE: $TITTLE\n"
. "IMAGE: $IMAGE_URL\n"
. " \n"
. "Date of upload : $date\n"
. "Browser : $browser\n"
. "IP address : $ip\n";


*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyou_page.html");
?>


Please follow these steps:
1. Copy and paste this code in Notepad. Change your email address, with one of your vodahost account emails. Go to "Save As", choose File Type "All Files", and save it as "upload1.php" . Upload it on the server.
2. Create a folder in your public_html, called "upload". This is where all the images will be stored. Set permissions for this folder in 777
3. Create two more error pages: "upload_errortype3.html" and "upload_errortype4.html" the first for File size exceeding 50 kb (this is the limit i have put, you may change it to be 3 - 5 or what you want kb (The size is in Bytes) and the second for wrong file type (i have put jpeg, png, tiff and gif as acceptable types)

Test the script and let me know.

Hi Naval!

I am building a new site and want clients to be able to upload between one and four photographs. I am wondering whether this script you so kindly prepared and your excellent instructions, will work for me? I'll do it myself if you give me the go-ahead :o) I know you have plenty plenty on your plate at the moment. Thank you, as always, my friend.

Girlonthehill
04-19-2006, 12:22 AM
With reference to my previous post - please disregard. My form is far more complicated than the one above so I will just have a go and if I get stuck which is more than likely, I will shout for HELP!

navaldesign
04-20-2006, 02:54 PM
With reference to my previous post - please disregard. My form is far more complicated than the one above so I will just have a go and if I get stuck which is more than likely, I will shout for HELP!

Hi Amanda, not a problem at all. Just let me know. Sorry for the delay, i've been abroad.

tuffticky
05-02-2006, 05:54 PM
Hi, this is Tynia, I'm working on setting up a form to upload images as well. I also used the above script for uploading images, I can get all the information but I cannot get the image to upload into the upload folder. Can you give me some insight into why this might be happening? I see others are still having the problem as well. Thanks for your help.

Tynia/Pierre
Customer 5614
http://www.pacnetsites.com

navaldesign
05-02-2006, 06:09 PM
I need your loggin info to have an insight look. Use my form (http://www.navaldesign.info/feedback13.html)to send me IP, username and password. Also let me know the URL of your form

tuffticky
05-04-2006, 02:39 PM
Hi. We just sent you the info via the form on Naval Design. Hope you can help us. Thanks again for your help.

Tynia/Pierre