在数据库里面建个表
记录上传文件的信息整个步骤如下:
1: 上传文件
2: 程序把文件信息记录到数据库(文件名,大小等),把文件copy到指定目录
3: 页面把所有属于该用户的文件列出来
4: 回到 1呵呵~~基本就是这样,当然还有细节问题例如怎么辨别文件属于哪个用户等的,我都是在数据库里面记录的~~到底要怎么做兄弟就要自己想了~~呵呵~~
记录上传文件的信息整个步骤如下:
1: 上传文件
2: 程序把文件信息记录到数据库(文件名,大小等),把文件copy到指定目录
3: 页面把所有属于该用户的文件列出来
4: 回到 1呵呵~~基本就是这样,当然还有细节问题例如怎么辨别文件属于哪个用户等的,我都是在数据库里面记录的~~到底要怎么做兄弟就要自己想了~~呵呵~~
<?
function mail2( $to, $subject, $message, $from, $content_type, $attache="")
{
if ( !empty($from) ) $head = "From: $from\n";
if ( !empty($to) ) $head .= "To: $to\n";
if ( !empty($subject) ) $head .= "Subject: $subject\n";
if ( empty($content_type) ) $content_type = "text/plain"; if ( is_array($attache) ) {
$boundary = "===" . md5(uniqid("")) . "===";
$head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; bounda
ry=\"". $boundary ."\"\n\nThis is a multi-part message in MIME format.
\n\n";
$head .= "--" . $boundary . "\n";
$head .= "Content-Type: $content_type\n";
$head .= "\n" . $message . "\n\n"; while ( list( $key, $val ) = each($attache) ) {
if( phpversion() >= "3.0.6" ){
$fd = fopen( $val, "r" ) or die("unable to open file $val");
$contents = chunk_split(base64_encode( fread( $fd, filesize( $val ) ) ));
fclose( $fd );
}else{ // need optimization to improve speed to handle large files
$contents = "";
$returnArray = "";
exec( "uuencode -m $val nothing_out",$returnArray);
for ($i = 1; $i<(count($returnArray) - 1); $i++){
$contents .= $returnArray[$i]. "\n";
}
}
$head .= "--" . $boundary . "\n";
$head .= "Content-Type: application/octet-stream; name=\"" . basename($val) . "\"\nContent-Transfer-Encoding: base64\nContent-Disposit
ion: attachment; filename=\"" . basename($val) . "\"\n";
$head .= "\n" . $contents . "\n\n";
}
$head .= "--" . $boundary . "--\n\n";
}else{
if ( !empty($content_type) ) {
$head .= "Content-Type: $content_type\n";
$head .= "\n" . $message . "\n";
}
}
return mail( "", "", "", $head );
}
?>