ok i want to do the same thing as you have here is my script i got but i am not shure where to put the bit you have dont in it!
############ <?
if($action1){ // if files have been uploaded, process them
?>
<?
set_time_limit(60); // make reasonably sure the script does not time out on large files
$path1 = AddSlashes("/home/sites/www.medicspro.com/uploads/");
// assign our path in a form PHP for Windows understands
for($i = 0; $i < 4; $i++){ // loop through the 4 possible files
switch($i){ // retrieve a file pointer from the temp directory
case 0:
$source = $file1;
$source_name = $file1_name;
break;
case 1:
$source = $file2;
$source_name = $file2_name;
break;
case 2:
$source = $file3;
$source_name = $file3_name;
break;
case 3:
$source = $file4;
$source_name = $file4_name;
break;
}
if(($source <> "none")&&($source <> "")){ // see if the file exists; non-existing file has name of "none"
if($error1 <> 1){ // no need to copy a file if directory not write-enabled
$dest = $path1.$source_name; // append file name to our path
if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success
echo "$source_name has been uploaded<br>\n";
$to = "aidanpeiser@hotmail.com"; // email admin about new uploaded file on server
$subject = "medicspro, $source_name file upload";
$body = "$source_name has beed uploaded ,check the uploads folder for the uploaded file,you will recieve a email for each file being uploaded.";
$from = "FROM: aidan <aidanpeiser@hotmail.com>";
mail ($to, $subject, $body, $from);
$to = "joseph.devasia@ecareermove.com";
$subject = "medicspro, new user file";
$body = "ask aidan for the file just been uploaded by a new user";
$from = "FROM: aidan <aidanpeiser@hotmail.com>";
mail ($to, $subject, $body, $from);
}
else {
echo "Upload directory not write-enabled\n"; // you need to write-enable the upload directory
$error1 = 1; // set flag
}
}
unlink($source); // delete the file from the temp directory
}
}
?>
<br><a href="uploadfile.php">Back</a>
</font></p>
</body>
<?
}
else { // else, prompt for the files
// files will be uploaded into the server's temp directory for PHP
?>
<head>
<title>File Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><b>File Upload</b><br><br>
Browse for your file on your computer and when you have selected the file click 'upload' <br>
<form method="post" enctype="multipart/form-data" action="uploadfile.php">
<input type="hidden" name="MAX_FILE_SIZE" value="400000">
<input type="hidden" name="action1" value="1">
Browse for file <input type="file" name="file1" size="30"><br>
<input type="hidden" name="file2" size="30"><br>
<input type="hidden" name="file3" size="30"><br>
<input type="hidden" name="file4" size="30"><br>
<input type="submit" value="Upload">
</form>
</font></p><br><br>
<?
}
?>
###################
where do i add you script lines.
$file = fopen($attach, "r");
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
thanks