此代碼實際上工作我沒有問題,但當我的領導問我讓上傳多個問題開始時,我的領導希望有2個上傳按鈕,以便當用戶點擊提交2個文件將保存在服務器文件夾中。在多次上傳中收到致命錯誤
indexaa.php
<?php
$smp_id = (int) @$_GET['i'];
$i = $db->get_row("select * from sample where smp_id='$smp_id'");
?>
<form name="form" enctype="multipart/form-data" method="post" action="upload.php">
<input type="hidden" name="smp_id" value="<? echo $smp_id ?>"/>
<table class='generic'>
<tr><td>Proposal Attachment</td><td><input type='file' name='file' value=''></td></tr>
<tr><td>Proposal Attachment</td><td><input type='file' name='file1' value=''></td></tr>
<tr><td colspan='2'>
<input type="submit" value="Submit" class="JSPOPUP_close">
<input type="button" value="Close" class="JSPOPUP_close">
</td></tr>
</table>
</form>
這行代碼<tr><td>Proposal Attachment</td><td><input type='file' name='file1' value=''></td></tr>
生病只需添加它,這樣我將有2個上傳按鈕。然後在upload.php我添加此行$file1 = fs_upload($_FILES['file1']);
以支持file1
,我添加這$sm_sql['presentation'] = $file1;
,以便file1
名稱將保存在我的示例表中,我忘記了什麼? 注:這是工作時,它不是多個上傳(1個文件上傳只)
upload.php的
<?
include("base_main.php");
$smp_id = (int) $_POST['smp_id'];
$file = fs_upload($_FILES['file']);
$file1 = fs_upload($_FILES['file1']);
$sm_sql['proposal'] = $file;
$sm_sql['presentation'] = $file1;
$insert = insertformat($sm_sql);
$query = $db->query("update sample set $insert where smp_id='$smp_id'");
if($query){
message_set("File uploaded: <a href='$fileserver_path/dex/$file'>$file</a> <a href='$fileserver_path/dex/$file1'>$file1</a>");
goback();
}
?>
這是class.upload.php
http://www.verot.net/download/class.upload.php/class.upload_0.25.txt
error: Fatal error: Cannot redeclare class upload in C:.....................\class.upload.php on line 363
鏈接
複製文件一旦上傳一次!除非你想要兩個不同的文件,否則你的問題不太清楚!無論如何,請檢查'fs_upload()'函數,並確保它不重新聲明上傳類 –