0
您能否告訴我如何在圖片正確加載時添加消息?添加一條警告消息:「圖片上傳成功」
(如果您對代碼的建議我很感謝)
<?
function upload()
{
$result = false;
$alwidth = 1150; // maximum allowed width, in pixels
$alheight = 1150; // maximum allowed height, in pixels
$max_size = 300000; // maximum file size, in KiloBytes
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); // allowed extensions
$immagine = '';
$size = 0;
$type = '';
$nome = '';
//check if its allowed or not
$allowtype = array(".jpg",".jpeg",".gif",".png");
if (!(in_array($file_ext, $allowtype))) {
die ('<h1 class=\"cover-heading\">Not allowed extension.<br />Please upload images only</h1>');
}
$type = $_FILES['file']['type'];
$nome = $_FILES['file']['name'];
$immagine = @file_get_contents($_FILES['file']['tmp_name']);
$immagine = addslashes ($immagine);
@include 'config.php';
$sql = "INSERT INTO immagini (nome, size, type, immagine) VALUES ('$nome','$size','$type','$immagine')";
$result = @mysql_query ($sql) or die (mysql_error());
return true;
}
?>