using System.IO;
using System.Drawing.Imaging;
private void Button1_ServerClick(object sender, System.EventArgs e)
{
Graphics g=null;
System.Drawing.Image upimage=null;
System.Drawing.Image thumimg=null;
System.Drawing.Image simage=null;
Bitmap outputfile=null;
try
{
string extension = Path.GetExtension(File1.PostedFile.FileName).ToUpper();
string filename = DateTime.Now.ToString("yyyyMMddhhmmss");
string smallpath = Server.Ma...
其中db_mysql.inc.php,config.php,function.php不是真正使用到的,关键是$filename 文件名,我是通过读取数据库中的图片名称。
以下是PHP代码:【复制代码】 <?phpinclude_once ('inc/db_mysql.inc.php');include_once ('inc/config.php');include_once ('class/function.php');global $picPath;
if (strstr($_SERVER[HTTP_USER_AGENT],"MSIE")) {$attachment = '';} else {$attachment = ' atachment;';}
$image = getInfo('newssp_gallery','id',$_GET['id']);
$filename = $picPath.$image['filename'];
if (!file_exists($filename)) {$filename = $picPath."notexist.gif...
写通用性程序考虑兼容性是很头痛的事情,关于用PHP生成缩略图的代码很多,不过能完全兼容gd1.6和gd2.x,并能保证缩图清晰性的代码几乎没有,我把我以前的代码改了一下,就能实现了。
function ImageResize($srcFile,$toW,$toH,$toFile="")
{
if($toFile==""){ $toFile = $srcFile; }
$info = "";
$data = GetImageSize($srcFile,$info);
switch ($data[2])
{
case 1:
 ...