I was one of the many people having trouble with attachments on an NT server. Here is my solution.
First I made a new testpage to check if uploading a file would work at all. I posted this form to a script echoing the uploaded filename, this gave me c:\winnt\temp\phpsometing.tmp. This file could be copied to one of my own directories using move_uploaded_file. This all worked fine so now I knew the bug must be somewhere in VB.
First thing I changed was echoing the uploaded filename in functions.php, in the function acceptupload. This time the filename was C:WINNTTEMPPHPSOMETHING.TMP... no slashes. So I added a line in this function:
to get the filename in the right format.
Next thing that went wrong was the line
For some reason this returned False when the file was still in the temp directory. So I had to copy the file to one of my directories first. My attachments are working now, thanks to the following lines in acceptupload:
Remaining question: why is the uploaded filename OK in my testscript and wrong in VB? Is this a VB bug and can this be solved?
First I made a new testpage to check if uploading a file would work at all. I posted this form to a script echoing the uploaded filename, this gave me c:\winnt\temp\phpsometing.tmp. This file could be copied to one of my own directories using move_uploaded_file. This all worked fine so now I knew the bug must be somewhere in VB.
First thing I changed was echoing the uploaded filename in functions.php, in the function acceptupload. This time the filename was C:WINNTTEMPPHPSOMETHING.TMP... no slashes. So I added a line in this function:
Code:
$attachment=ereg_replace("C:WINNTTEMP", "C:\\WINNT\\TEMP\\", $attachment);
Next thing that went wrong was the line
Code:
if (file_exists($attachment)) {
Code:
$attachment=ereg_replace("C:WINNTTEMP", "C:\\WINNT\\TEMP\\", $attachment); $tmppath=tempnam ("d:\\www\\nldelphi.com\\database", "UPL"); copy($attachment, $tmppath); $attachment=$tmppath;
Comment