兩個文件我想在HTML文件上傳如下:無法上傳在PHP
<tr><td><?php _e("Upload Trust Logo","emarksheet"); ?></td><td><label class="btn btn-danger" for="file-sel"><input id="file-sel" type="file" name="imaget" style="display:none;" size="25" />Browse to Upload Logo ....</label></td></tr>
<tr><td><?php _e("Upload Institute Logo","emarksheet"); ?></td><td><label class="btn btn-primary" for="file-sel2"><input id="file-sel2" type="file" name="image" style="display:none;" size="25" />Browse to Upload Logo ....</label></td></tr>
兩個上傳這些文件。我的php代碼如下:
$path = plugin_dir_path(__FILE__);
$file = $_FILES['image'];
//print_r($_FILES);
$name1 = $file['name'];
$type = $file['type'];
$size = $file['size'];
$tmppath = $file['tmp_name'];
move_uploaded_file ($tmppath, $path.'logos/'.$name1);
//upload data end
//upload trust logo`
$file2 = $_FILES['imaget'];
//print_r($_FILES);
$name2 = $file2['name'];
$type2 = $file2['type'];
$size2 = $file2['size'];
$tmppath2 = $file2['tmp_name'];
move_uploaded_file ($tmppath2, $path.'logos/'.$name2);
當我上傳文件。與$name2
文件名上傳但名稱$name1
文件沒有被上傳
請幫助爲什麼不能上傳
首先使用'print_r($ _ FILES)'檢查將會出現什麼值。 – Yash
當我更改ID'file-sel2'到'file-sel'時,我得到'Array([imaget] => Array([name] => IMG_20151020_205510.jpg [type] => image/jpeg [tmp_name] = > E:\ wamp \ tmp \ php803D.tmp [error] => 0 [size] => 2706889)[image] => Array([name] => [type] => [tmp_name] => [error] = > 4 [size] => 0))' –
否則它是空白的數組 –