/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] email notification after uploading images? need help with the script.

I used the script by Bokeh for uploading images using PHP but it’s a foreign language to me so I don’t know how to customize the script. I am checking to see if anyone knows what I need to add in (and where) so that after a file is uploaded an email is sent to notify the business that a file has been uploaded?

Here is a link to his thread so u can see what I am using.
[url]http://www.webdeveloper.com/forum/showthread.php?t=101466[/url]

Any help would be greatly appreciated!!!

to post a comment
PHP

18 Comments(s)

Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — Just before this:
[code=php]// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to a success page.
header('Location: ' . $uploadSuccess); [/code]


Put this:
[code=php]
$email= ; //who the email should be sent to
$subject = "New Photo Upload!"; //subject
$body = "Dear $first,nThere has been a new image uploaded on OurSite.com"; // the body of the email
$headers = "From: [email protected]"; //Who the email came from, you can also put a reply-to tag in here incase they do reply.
mail($email,$subject,$body,$headers); //sends it all
[/code]
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — You are awesome!! That worked perfectly. What do you mean by putting in a "reply-to tag"? I was thinking that it would be a professional courtesy to send the person who uploaded files a confirmation email as well. Got a quick add in for that too? Thanks in advance! ?
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — No problem. Whenever you want to put in an email confirmation just put it right before the success action (which is usually a header() command). Thus, just before they get a message that their upload worked it will send them an email.

if you change:
[code=php]$headers = "From: [email protected]";[/code]
To:
[code=php]$headers = "From: [email protected]". "rn" ."Reply-To: [email protected]";[/code]

When/If someone replies to the email that gets sent to them, you will get the reply mail. Otherwise it will be sent back to your server and ultimately lost.
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — hmmm.. with that script an email is sent to the business with the from as "[email protected]" then there is a reply-to "[email protected]". I want the "reply to" to be the uploaders email because my submit form requires them to put in their name, email and any additional comments. Also, when the email is sent to the business I want to body of the email to include all the stuff the uploader put in.. did that make sense because I think all this is making me go crazy! kudos to you for understanding all this and thanks again!

Here is a link to the site I am working on.

http://creativcat.com/projects/rapidweb/multiple.upload.form.php
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — ooo. thats a slick little site ?

umm. lets see....

if you want it to be the uploaders information then do this...(replace the variables to whatever you use)

[code=php]$headers = "From: $uploaderemail". "rn" ."Reply-To: $uploaderemail"; [/code]

For the body of the email to contain their name and other such information do this:

[code=php]$body = "Dear $first,nThere has been a new image uploaded on OurSite.com by $uploadernamenUploader's E-Mail: $uploaderemailnnAdditional Comments:n$artworkcomments"; // the body of the email[/code]

oh and FYI, the n act as enters or returns, there is also no need to space after them (it may make your email look all weird).
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — oh thank god that worked!! i swear once i think I'm finally done something else comes up.. ok lets see if u can figure this one out. My upload form will take jpg, gif and png so far but its gives me an error that the file is not an image if i try to upload a pdf or .sit file. ?????? those are the main file formats that I would assume people would send!
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — well you are using an image upload form so its set to ONLY accept image formats.

i see in the code you're using this piece of script:
[code=php]// validation... since this is an image upload script we should run a check

// to make sure the uploaded file is in fact an image. Here is a simple check:
// getimagesize() returns false if the file tested is not an image.
@getimagesize($_FILES[$fieldname]['tmp_name'])
or error('only image uploads are allowed', $uploadForm);[/code]


when you dont upload an image it returns false and gives you an error, so this is what we need to change. ?

I use this in one of my upload forms, it may just plug straight in. Try and replace the above code and then try and upload a PDF again, if it gives you an error then it half works, then try and upload an image then it works 100% then let me know and ill change it around to accept PDF and .sit (we just need to make sure its actually filtering the files and not just letting everything through.

[code=php]if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 1000000))
{
if ($_FILES["file"]["error"] > 0)
{
$error = $_FILES["file"]["error"];
error('only image uploads are allowed', $uploadForm);
}[/code]
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — tried to upload a pdf and this is what i got...

Parse error: parse error, unexpected $ in /home/content/k/s/c/kschroers/html/projects/rapidweb/multiple.upload.processor.php on line 134


line 134 is the end of the file ???
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — Ack that was me...try this i missed a }

[code=php]if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 1000000))
{
if ($_FILES["file"]["error"] > 0)
{
$error = $_FILES["file"]["error"];
error('only image uploads are allowed', $uploadForm);
}
}[/code]
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — wait....you're using the multiple upload? i was going off the single one...let me modify the script real quick...
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — have i told u yet that u r feakin sweet for taking the time to do this!!!!
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — Here, This:
[code=php]foreach($active_keys as $key)
{
if ((($_FILES[$fieldname]["type"] == "image/gif")
|| ($_FILES[$fieldname]["type"] == "image/jpeg")
|| ($_FILES[$fieldname]["type"] == "image/png")
|| ($_FILES[$fieldname]["type"] == "image/bmp")
|| ($_FILES[$fieldname]["type"] == "image/pjpeg"))
&& ($_FILES[$fieldname]["size"] < 1000000))
{
if ($_FILES[$fieldname]["error"] > 0)
{
$error = $_FILES["file"]["error"];
error('only image uploads are allowed', $uploadForm);
}
}
}[/code]


Replaces this:
[code=php]foreach($active_keys as $key)
{
@is_uploaded_file($_FILES[$fieldname]['tmp_name'][$key])
or error($_FILES[$fieldname]['tmp_name'][$key].' not an HTTP upload', $uploadForm);
} [/code]
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — Hah, dont mention it. ?

i have fun with PHP i see it as a puzzle.

see if that works...if not i may have to add in [$key] at the end of each $_FILES array
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — oh, this would be an appropriate time to create a lil smilie doing a celebratory dance!! Thank you sooo much!!!!!!!!!!!!!!!! I need to stick to designing and find someone else to do all this developer stuff but like you I enjoy the challenge and mystery behind it all.

hey, since you have proven to be such a genius.. do u know anything about using autoviewer? I have another post out there that no one has tried to tackle. Here it is if u r up to the task:

https://webdeveloper.com/forum/showthread.php?t=188264
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — haha, well i guess if you get too over whelmed i can do some of it for ya ?

ill check it out...
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — bad news, im not much of an xml fan.

i know tid bits but not enough to work through your problem ?

im sorry. if you have any other PHP stuff you need thats one of my specialties ?
Copy linkTweet thisAlerts:
@kschroersauthorAug 06.2008 — hey thanks for looking. I already owe u big time. Keep me in mind if u ever run into any design issues.. i think that's the only area in which I could pay you back.
Copy linkTweet thisAlerts:
@JeremyAAug 06.2008 — hehe, sure will ?
×

Success!

Help @kschroers spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...