Page 1 of 1
Need help with an upload PHP code
Posted: Wed Jun 17, 2009 8:07 am
by groogruxking40
I'm running Wordpress 2.8
I would like a script that lets the customer upload a file (jpg,png,gif,etc) pretty much an image file.
Then I would like that file to
(a) be uploaded to my server
(b) a copy sent via e-mail to me
any help?? I know there are some geniuses out there!
Re: Need help with an upload PHP code
Posted: Wed Jun 17, 2009 9:16 am
by dankolle
Code: Select all
//GET IMAGE INFO
$dir = 'images/';
$file_name = $_FILES['file']['name'];
$file_tmp = $_FILES['file']['tmp_name'];
//CHECK FOR UPLOADED FILE
if(is_uploaded_file($file_tmp)){
//MOVE TO DIR
move_uploaded_file($file_tmp, $dir.$file_name);
}
That should upload the file for you, then just change the directory to the image directory and make sure the permissions are 777 on the folder. Then just use your URL to send the image to you
Re: Need help with an upload PHP code
Posted: Wed Jun 17, 2009 9:30 am
by groogruxking40
Thank you so much!!
haven't tried it yet,but I will
now do I just attached a mailto command at the end for it to shoot to my e-mail or what?
Thanks again

Re: Need help with an upload PHP code
Posted: Wed Jun 17, 2009 12:44 pm
by McInfo
You can send yourself an HTML mail that includes an <img> tag whose src attribute points to a PHP script that returns the image. Or you can embed the image in the email with base-64 encoding. The first method reduces the size of your emails. Look around on this forum for some examples of both of these methods.
Use the mail() function to actually send the email.
PHP Manual:
mail
Edit: This post was recovered from search engine cache.
Re: Need help with an upload PHP code
Posted: Wed Jun 17, 2009 12:55 pm
by groogruxking40
Ok I got all of that, now do I just upload the .php to my server? or do I actually copy/paste the code on the page I want the form/image upload?
Re: Need help with an upload PHP code
Posted: Wed Jun 17, 2009 2:05 pm
by McInfo
What ".php" are you referring to? Can you elaborate on what you mean by "copy/paste the code on the page I want the form/image upload"?
Edit: This post was recovered from search engine cache.