-1
UploadImage.php
define ('MAX_FILE_SIZE', 1024 * 50);
if ((isset($_POST['MM_insert'])) && ($_POST['MM_insert'] =="uploadImg")) {
// make sure it's a genuine file upload
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
// replace any spaces in original filename with underscores
$filename = str_replace(' ', '_', $_FILES['image']['name']);
// ...
}
}
HTML模板:
<form action="UploadImage.php" method="post"
enctype="multipart/form-data" name="uploadImg" id="uploadImg">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="MAX_FILE_SIZE" />
<label for="image">Upload image:</label>
<input type="file" name="image" id="image" />
</p>
<p>
<input type="submit" name="upload" id="upload" value="Upload" />
</p>
<input type="hidden" name="MM_insert" value="uploadImg" />
</form>
這給出了一個錯誤; undefined index: image in ....... UploadImage.php
我已經給ENCTYPE形式屬性太... BT它給一個未定義的指標eror :(
您的文件大小太大,因爲在php.ini文件中指定 – 2012-05-19 06:44:46
嘗試調試$ _FILES ['image'] ['tmp_name']或使用isset。 –
我用isset和錯誤沒有更多的顯示,但沒有數據已經插入到數據庫... – user1404729