Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173158 is a reply to message #173156] |
Fri, 25 March 2011 03:01 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Thu, 24 Mar 2011 15:26:21 -0500, Tim wrote:
> In article <4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>
>> On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>>
>>> In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan
>>> Stein <jstein(at)image(dot)dk> wrote:
>>>
>>>> On 23-03-2011 19:05, Tim wrote:
>>>>
>>>> > I also find it strange, and very frustrating, that I seem to have
>>>> > to become a php expert just to make this one form page behave the
>>>> > way I want.
>>
>>>> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-
in-
>> HTML-Em
>>>> ail-P113.html
>>
>>> I looked at that briefly. I hadn't searched for that exact string so
>>> I suppose that is why I hadn't seen it before.
>>>
>>> It is on the right track, though it would require a lot of
>>> modification to get it to work with my existing code since it uses an
>>> image located on the server and whose name is known.
>>
>> If you don't know what the file name of the image file is, how the heck
>> do you expect to be able to do anything at all with it?
>>
>> Perhaps your questions should start with:
>>
>> "How do I find out where the uploaded file is, and what it was called?"
>>
>> http://uk2.php.net/manual/en/reserved.variables.files.php
>>
>> After you have absorbed that information, perhaps you will then be
>> ready to ask "How do I use PHP to email this uploaded image to someone
>> else?"
> Thanks for the concern, but I already have the form and handler code
> that gets the file's name. I was just pointing out that the example at
> that link was using a pre-existing image file, rather than an uploaded
> one, and hard-coding it into the script.
Yes, and? You simply have to write code that uses your filename wherever
that code uses the hardcoded filename. It's not difficult.
> This is all about getting the data, including the image, to me in the
> desired format so I can print it out without needing to make
> modifications to it such as placing the attached image where I want it.
ok, maybe the second question should have been:
"How do I use PHP to email this uploaded image to someone?"
where "someone" might include yourself.
Here's what happens:
File is uploaded in a form. It gets put in a temporary location. The
$_FILES superglobal contains:
a) original filename from uploading system
b) mime type
c) temporary name
d) status
e) size
(possibly not in that order)
mime type might not be valid, there's a suggestion it's supplied by the
uploader. original filename might also not be valid.
First of all you should use move_uploaded_file to put the file in your
"incoming uploads" directory. At this point, you can also rename it to
whatever you want to call it. You might or might not choose to use some
or all of:
uploading system ip
date and time
original filename
to create a unique name, after all you can't have two files of the same
name in your temp dir. Or you could just number incoming files
sequentially starting at 1. What I'd probably do is make a note of the
original name, uploaders ip, time and date, create an md5 hash from it
and use that as the unique filename, and record the original information
in a log file.
However, as you want to send an email, you could stick that information
in the message body, together with the unique filename that you gave it
in your incoming uploads directory
So once you have the file in your incoming uploads directory, with
whatever filename you choose to give it derived however you decided to
derive it, you can now, by using a slightly modified version of the email
example that you have already been provided with, email it to yourself.
We're not expecting you to become an expert, but please, to make the php
code to do what you want it to, you have to meet it half way and be
prepared to string a few functions and control statements together.
If you're not capable of editing an example of code that uses a hardcoded
filename to use a variable one instead, then maybe you need to spend some
more time getting to grips with the basics of programming concepts and
editing files, and then the variable naming syntaxes etc of php, before
you start working on anything as ambitious as form handling, uploaded
files and sending emails.
Rgds
Denis McMahon
|
|
|