我正在使用脚本来管理我的mysql数据库。该脚本能够上传部分条目的图像。但是,每当我点击上传,没有任何反应,没有成功或错误消息。下面是代码,希望有人可以查明问题。提前谢谢。
脚本演示: www.keretapi.com/lineclear/tm_customer.php
tm_customer.php代码:
<?php
$CONFIG['debug'] = 'on'; // on or off, if it is on all mysql errors will be reported
$CONFIG['dbhostname'] = 'localhost';
$CONFIG['dbusername'] = 'keretapi_lc';
$CONFIG['dbpassword'] = 'keretapi1984';
$CONFIG['dbname'] = 'keretapi_lineclearexpress';
// connect to the database
$db = mysql_connect($CONFIG['dbhostname'],$CONFIG['dbusername'],$CONFIG['dbpassword']) or displayerror('could not connect');
mysql_select_db($CONFIG['dbname'],$db);
// the name of the mysql database table
$CONFIG['tablename'] = 'test';
// a descriptive name given to a single record table, e.g Product, Customer, News Article etc
$CONFIG['recordname'] = 'Consignments';
// the field name of the primary key in the database table
$CONFIG['primarykey'] = 'WaybillNo';
// the field name of the field which will be used to search for records
$CONFIG['searchfield'] = 'WaybillNo';
$CONFIG['title'] = 'Consignments';
$CONFIG['pagesize'] = 1000; // how many records per page?
$FIELDS['WaybillNo']['description'] = 'Waybill No.';
$FIELDS['WaybillNo']['listdisplay'] = 1;
$FIELDS['WaybillNo']['editdisplay'] = 1;
$FIELDS['WaybillNo']['editable'] = 1;
$FIELDS['WaybillNo']['type'] = 'input';
$FIELDS['WaybillNo']['length'] = 14;
$FIELDS['WaybillNo']['required'] = 1;
$FIELDS['WaybillNo']['explanation'] = '';
$FIELDS['WaybillDate']['description'] = 'Waybill Date';
$FIELDS['WaybillDate']['listdisplay'] = 1;
$FIELDS['WaybillDate']['editdisplay'] = 1;
$FIELDS['WaybillDate']['editable'] = 1;
$FIELDS['WaybillDate']['type'] = 'input';
$FIELDS['WaybillDate']['length'] = 10;
$FIELDS['WaybillDate']['required'] = 1;
$FIELDS['WaybillDate']['explanation'] = '';
$FIELDS['ShipperName']['description'] = 'Shipper Name';
$FIELDS['ShipperName']['listdisplay'] = 1;
$FIELDS['ShipperName']['editdisplay'] = 1;
$FIELDS['ShipperName']['editable'] = 1;
$FIELDS['ShipperName']['type'] = 'input';
$FIELDS['ShipperName']['length'] = 200;
$FIELDS['ShipperName']['required'] = 1;
$FIELDS['ShipperName']['explanation'] = '';
$FIELDS['ShipperName']['listdisplaysize'] = '200';
$FIELDS['Destination']['description'] = 'Destination';
$FIELDS['Destination']['listdisplay'] = 1;
$FIELDS['Destination']['editdisplay'] = 1;
$FIELDS['Destination']['editable'] = 1;
$FIELDS['Destination']['type'] = 'input';
$FIELDS['Destination']['length'] = 200;
$FIELDS['Destination']['required'] = 1;
$FIELDS['Destination']['explanation'] = '';
$FIELDS['Destination']['listdisplaysize'] = '200';
$FIELDS['Status']['description'] = 'Status';
$FIELDS['Status']['listdisplay'] = 1;
$FIELDS['Status']['editdisplay'] = 1;
$FIELDS['Status']['editable'] = 1;
$FIELDS['Status']['type'] = 'text';
$FIELDS['Status']['length'] = 1000;
$FIELDS['Status']['required'] = 0;
$FIELDS['Status']['explanation'] = '';
$FIELDS['Status']['listdisplaysize'] = '1000';
$FIELDS['image1']['description'] = 'Image';
$FIELDS['image1']['listdisplay'] = 1;
$FIELDS['image1']['editdisplay'] = 1;
$FIELDS['image1']['editable'] = 1;
$FIELDS['image1']['type'] = 'directoryimage';
$FIELDS['image1']['required'] = 0;
$FIELDS['image1']['explanation'] = '';
$FIELDS['image1']['imagesizes'] = array('150x150','300x300');
$FIELDS['image1']['imagedirectory'] = '/home/keretapi/public_html/lineclear/images/';
$FIELDS['image1']['maxuploadsize'] = 1000000;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $CONFIG['title']; ?></title>
</head>
<body>
<?php include('tm_files/tablemanager.php'); ?>
</body>
</html>
tablemanager.php代码:
foreach($FIELDS as $field => $details) {
if($details['type'] == 'directoryimage') {
if($_FILES[$field]['name']) {// if a file was actually uploaded
if($_FILES[$field]['size'] > 0 && $_FILES[$field]['size'] < $details['maxuploadsize']) {
$pathparts = pathinfo($_FILES[$field]['name']);
$ext = strtolower($pathparts['extension']);
if($ext == 'jpeg') { $ext = 'jpg'; }
if($ext == 'jpg' OR $ext == 'png' OR $ext == 'gif' OR $ext == 'bmp') {
// create the master file
$filename = $_FILES[$field]['name'];
$masterpath = "$details[imagedirectory]/master-$insertid";
move_uploaded_file($_FILES[$field]['tmp_name'], $masterpath);
// create the thumbnail
exec("convert -size 80x80 $masterpath -resize 80x80 +profile \"*\" $details[imagedirectory]/thumb-$insertid.jpg");
foreach($details['imagesizes'] as $size) {
exec("convert -size 80x80 $masterpath -resize 80x80 +profile \"*\" $details[imagedirectory]/$size-$insertid.jpg");
}
unlink($masterpath);
}
}
}
}
}
} elseif($_REQUEST['save']) { // if the modify button was pressed to save the form
foreach($FIELDS as $field => $details) { // change the format of date fields
if($details['editable'] == 1 AND $details['editdisplay'] == 1 AND $details['type'] == 'date') {
$dateparts = explode('/',$_POST[$field]);
$_POST[$field] = $dateparts[2].'-'.$dateparts[1].'- '.$dateparts[0];
}
}