Jabbamonkey
09-10-2002, 05:44 PM
Well, I'm running into some more file upload problems... This worked fine, but when I modified it, I'm running into trouble... I have a web form that allows users to submit attachments. When submitted, the script sends the site owner an email with the attachments.
Here's the script....
if ($numberfiles >= 1)
// numberfiles is declared when the file is sent to this page
{
$countin = array();
$countnext = 1;
// there may be multiple files to upload. if so...
for ($i = 0; $i < $numberfiles; $i++)
{
$countin[$i] = $countnext;
$countnext++;
}
for($i = 0; $i < $numberfiles; $i++)
{
if (${"userfile$countin[$i]"} !=="")
{
$thefile = ${"userfile$countin[$i]"};
$thefile_name = ${"userfile$countin[$i]_name"};
$thefile_type = ${"userfile$countin[$i]_type"};
$pathonserver = "D:\\\\SERVER\\\\123\\\temp\\\";
$fileonserver = $pathonserver.$thefile_name;
copy($thefile, $fileonserver);
unlink($thefile);
// FILE UPLOADED
// GET FILE DATA
$file = fopen($fileonserver,'rb');
${"data$countin[$i]"} = fread($file,filesize($fileonserver));
fclose($file);
}
}
}
I tried echoing out all the variables, and got the following (NOTE: the data variable is MISSING)
file: d:\PHP\uploadtemp\php177.tmp
file: _ba60582_b.jpg
file: image/pjpeg
file: D:\SERVER\123\temp\_ba60582_b.jpg
file copied
Data:
Anyone know why the data variable is not there? That's what's messing up the script (the email I recieve contains corrupted files with no data).
Jabbamonkey
Here's the script....
if ($numberfiles >= 1)
// numberfiles is declared when the file is sent to this page
{
$countin = array();
$countnext = 1;
// there may be multiple files to upload. if so...
for ($i = 0; $i < $numberfiles; $i++)
{
$countin[$i] = $countnext;
$countnext++;
}
for($i = 0; $i < $numberfiles; $i++)
{
if (${"userfile$countin[$i]"} !=="")
{
$thefile = ${"userfile$countin[$i]"};
$thefile_name = ${"userfile$countin[$i]_name"};
$thefile_type = ${"userfile$countin[$i]_type"};
$pathonserver = "D:\\\\SERVER\\\\123\\\temp\\\";
$fileonserver = $pathonserver.$thefile_name;
copy($thefile, $fileonserver);
unlink($thefile);
// FILE UPLOADED
// GET FILE DATA
$file = fopen($fileonserver,'rb');
${"data$countin[$i]"} = fread($file,filesize($fileonserver));
fclose($file);
}
}
}
I tried echoing out all the variables, and got the following (NOTE: the data variable is MISSING)
file: d:\PHP\uploadtemp\php177.tmp
file: _ba60582_b.jpg
file: image/pjpeg
file: D:\SERVER\123\temp\_ba60582_b.jpg
file copied
Data:
Anyone know why the data variable is not there? That's what's messing up the script (the email I recieve contains corrupted files with no data).
Jabbamonkey