I have a small form in which the user uploads a file. What I want to do is to e-mail the file directly from its tmp location, without moving it first; because there’s no need to store it on the server. Because PHP removes the file from the tmp folder after execution of the script, this would be ideal.
I’m using Manuel Lemos’s fantastic Mime message e-mail class, and can do this:
$tmp_file = '/www/vhosts/mysite.be/subdomains/subdomainname/httpdocs'.$_FILES['attachment']['tmp_name'];
$attachment=array(
"FileName" => $_FILES['attachment']['name'],
"Content-Type" => $_FILES['attachment']['type'],
"Data" => $tmp_file,
"Disposition" => "attachment"
);
$email_message->AddFilePart($attachment);
The problem is that I cannot seem to retrieve the file from its tmp location. I’m on a shared hosting system.
Can anyone share viewpoints / answers? Looking forward to your views.
P.S.: Please note there is no problem with upload limits / timeouts / enctype …
You shouldn’t need to put the directory for the
$tmp_fileas the tmp_name already contains this. Also check that the file exists as a way of debugging it.See what happens after this.