![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[ph
<?php
include_once"../inc/global.php";
if ($Submit != '')
{
$fileArr['file'] = $file;
$fileArr['name'] = $file_name;
$fileArr['size'] = $file_size;
$fileArr['type'] = $file_type;
/** 所允许上传的文件类型 */
$filetypes = array('gif','jpg','jpge','png',"exe");
/** 文件上传目录 */
$savepath = "..\uploadimage\\";//在此必须要在文件夹名后面加个两个"\\",否则,上传后的文件将被重命名.
/** 没有最大限制 0 无限制*/
$maxsize = 0;
/** 覆盖 0 不允许 1 允许 */
$overwrite = 0;
$upload = new upload($fileArr, $file_name, $savepath, $filetypes, $overwrite, $maxsize);
if (!$upload->run())
{
$resultUploadMsg= "上传失败:".$upload->errmsg();
}
else
{
//将图片信息插入数据库
$dates=date('Y-m-d H:i:s');
$connecton = ADONewConnection("mysql"); //总是在这里提示错误 $connection->Connect(SERVER, USER, PASS, DBNAME);
$imageSql="INSERT INTO mate_photos VALUES('','$file_name','$_SESSION[user]','$date')";
if(!$connection->ExeCute($imageSql))
{
$resultUploadMsg .="数据库插入失败!";
}
else{
$resultUploadMsg="上传成功!";
}
}
}//end if submit==true
//注册smarty组件应用
$smarty=new Smarty();
$smarty->force_compile =false; //强迫编绎
$smarty-> compile_check = true;
$smarty->template_dir = "../template";//设置模板目录
$smarty->compile_dir = "../tmp"; //设置编译目录
$smarty->compile_check=true;
/*---------------------------------------------------
左右边界符,默认为{},但实际应用当中容易与JavaScript
相冲突,所以建议设成<{}>或其它。
----------------------------------------------------*/
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
//smarty组装
$smarty->assign('resultUploadMsg',$resultUploadMsg);
$smarty->display("upload.tpl");
?>
[/php]

