Unable to set upload_tmp_value
| From: | brian teh | Date: | Wed, 22 Apr 2009 04:00:59 +0000 |
| Subject: | Unable to set upload_tmp_value | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-4502@lists.php.net to get a copy of this message | ||
Hi,
I'm writing this email because I'm unable to find a solution for my problem.
I'm creating an email with enable user to send attachment in the email but
the file is not attached to the email successfully.
$fileatt = $_FILES['fileUpload']['tmp_name'];
$fileatt_type = $_FILES['fileUpload']['type'];
$fileatt_name = $_FILES['ffileUpload']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
mail($to, $subject, $message, $headers);
What I discover is the program unable to retrieve information of the
uploaded file.
The following values are null:
- $fileatt
- $fileatt_type
- $fileatt_name
In my php.ini, I have configured the path for upload_tmp_dir
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = "C:\TEMP"
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
but when I view the php info in html, the upload_tmp_dir = no value
My questions are:
1. To create an email with attachment, setting value for
upload_tmp_dir is it a compulsory? Is there any additional parameters that
need to be set in php.ini?
2. After setting the value for upload_tmp_dir in php.ini, why it is
not reflected in info.html?
3. Do we need to provide the full file path for upload_tmp_dir?
I'm using IIS v5.1, php 5.2.9, OS Win XP.
Hope you can help me resolve my problem. Thanks in advance.
Regards,
Brian Teh
The information contained in this email inclusive of all attachments may be
confidential and /or legally privileged. If you are not the intended
recipient(s), you are hereby notified that any dissemination, distribution,
publication, copying or other use of the information contained in this email
is strictly prohibited and unlawful. If you have received this email in
error, pls delete all copies of this email and notify the sender.