第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

PHP move_uploaded_file()函數(shù)不起作用

PHP move_uploaded_file()函數(shù)不起作用

PHP
慕哥6287543 2021-04-27 13:46:56
獲得了將產(chǎn)品添加到網(wǎng)上商店的表單。您最多可以上傳10張圖片,最少可以上傳1張圖片。即使將文件名完美地插入到MySQL數(shù)據(jù)庫(kù)中,文件也不會(huì)移動(dòng)到正確的文件夾中。我正在使用共享的Web主機(jī)PHP 5.2,該文件具有寫(xiě)權(quán)限。已經(jīng)與虛擬主機(jī)進(jìn)行過(guò)交談,這不是權(quán)限問(wèn)題。<form action="" method="post" enctype="multipart/form-data">                  <div class="form-group">                    <label for="img1"><b>Image 1</b></label>                    <input required type="file" class="form-control" name="img1" placeholder="Image 1 (name of the first image, upload it as instructed)">                  </div>                  <div class="form-group">                    <label for="img2"><b>Image 2</b></label>                    <input type="file" class="form-control" name="img2" placeholder="Image 2 (name of the first image, upload it as instructed)">                  </div>                  <div class="form-group">                    <label for="img3"><b>Image 3</b></label>                    <input type="file" class="form-control" name="img3" placeholder="Image 3 (name of the first image, upload it as instructed)">                  </div>                  <div class="form-group">                    <label for="img4"><b>Image 4</b></label>                    <input type="file" class="form-control" name="img4" placeholder="Image 4 (name of the first image, upload it as instructed)">                  </div>                  <div class="form-group">                    <label for="img5"><b>Image 5</b></label>                    <input type="file" class="form-control" name="img5" placeholder="Image 5 (name of the first image, upload it as instructed)">                  </div>     獲取文件名稱并將其移動(dòng)到正確文件夾的部分。這些文件沒(méi)有移到旋轉(zhuǎn)木馬文件夾,而是根本沒(méi)有移到任何地方:[Thu Apr 18 18:53:34.249395 2019] [cgi:error] [pid 13994] [client 172.69.130.13:32306] AH01215: PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpOjN6YW' to '../assets/img/carousel/download (2).jpg' in /home/seniorte/public_html/admin/add.php on line 338: /usr/local/cpanel/cgi-sys/ea-php56Error log ^   
查看完整描述

2 回答

?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

所以Cherrysoft所說(shuō)的是正確的。它幾乎可以肯定是權(quán)限問(wèn)題,或者不符合您的想法。


我將利用這個(gè)機(jī)會(huì)來(lái)幫助您改進(jìn)代碼。您的示例可以簡(jiǎn)化,以便更輕松地添加10個(gè)以上的圖像,并且更易于維護(hù)。這是您當(dāng)前代碼的更好替代方法:


if(isset($_POST['name'])){

    foreach($_FILES as $key => $file) {

        move_uploaded_file($file['tmp_name'],"../assets/img/carousel/{$file['name']}");

    }

}

這樣,您的代碼就不會(huì)那么重復(fù)了。有一些方法可以進(jìn)一步改善這一點(diǎn),但是我不想被迷住。


查看完整回答
反對(duì) 回復(fù) 2021-05-07
  • 2 回答
  • 0 關(guān)注
  • 275 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)