Specifications

Strictly speaking, we should probably also check the $list and $mailid variables for
unwanted characters, but we have ignored this for the sake of brevity.
Next, we set up and send the headers for the page, and validate that the form was filled in cor-
rectly. This is important here as its quite a complex form for the user to fill out.
Then we create an entry for this mail in the database, and set up a directory in the archive for
the mail to be stored in.
Next comes the main part of the script, which checks and moves each of the uploaded files.
This is the part that is different when uploading multiple files. We now have three arrays to
deal with. These arrays are called $userfile, $userfile_name, and $userfile_size. They corre-
spond to their similarly named equivalents in a single file upload, except that each of them is
an array. The first file in the form will be detailed in $userfile[0], $userfile_name[0], and
$userfile_size[0].
Given these three arrays, we perform the usual safety checks and move the files into the archive.
Finally, we give the administrator some buttons that they can use to preview the newsletter they
have uploaded before they send it, and a button to send it. You can see the output from
upload.php in Figure 28.13.
Building Practical PHP and MySQL Projects
P
ART V
702
FIGURE 28.13
The upload script reports the files uploaded and their sizes.
Previewing the Newsletter
There are two ways the administrator can preview a newsletter before sending. She can access
the preview functions from the upload screen if she wants to preview immediately after upload.
34 7842 CH28 3/6/01 3:46 PM Page 702