2014-02-24 97 views
0

我有兩個文件上傳字段。我的第一個字段文件上傳成功,但第二個文件不成功。但在數據庫中所有文件名都存儲正確。文件上傳不工作PHP

<?php 
if(isset($_POST['btnportfolio'])) 
{ 
      $picture_name1 =time().'-' .$_FILES["picture1"]["name"]; 

      $picture_name2 =time().'-' .$_FILES["picture2"]["name"]; 


    $c->setImage_one($picture_name1); 

    $c->setImage_two($picture_name2); 


       if($c->Insert()) 
           { 


       move_uploaded_file($_FILES["picture1"]["tmp_name"], "Slideshow/" . $picture_name1);         
       move_uploaded_file($_FILES["picture2"]["tmp_name"], "Slideshow/" . $picture_name2);         


            print '<div class="alert alert-success">Insert Successfully</div>'; 

            $c = new Slideshow(); 
        ?> 
             <script>setTimeout('top.location = \'?a=slideshow\'', 500);</script> 
        <?php 
           } 
           else 
           { 
            print '<span>'.$c->getErr().'<span>'; 
           }   
} 

?> 

這是我的HTML表單代碼

 <div class="form-group"> 
      <label for="inputPassword3" class="col-sm-2 control-label">Image Item One</label> 
      <div class="col-sm-10"> 
        <div class="fileupload fileupload-new" data-provides="fileupload"> 
        <span class="btn btn-primary btn-file"><span class="fileupload-new">Select file</span> 
        <span class="fileupload-exists">Change</span>   
        <input type="file" name="picture1" id="picture1"/></span> 
        <span class="fileupload-preview"></span> 
        <a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a> 
        </div> 
      </div> 
     </div> 





     <div class="form-group"> 
      <label for="inputPassword3" class="col-sm-2 control-label">Image Item Two</label> 
      <div class="col-sm-10"> 
        <div class="fileupload fileupload-new" data-provides="fileupload"> 
        <span class="btn btn-primary btn-file"><span class="fileupload-new">Select file</span> 
        <span class="fileupload-exists">Change</span>   
        <input type="file" name="picture2" id="picture2"/></span> 
        <span class="fileupload-preview"></span> 
        <a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a> 
        </div> 
      </div> 
     </div> 

我無法理解,爲什麼只有一個文件uploaded.I感到困惑。

回答

0

你需要

<form enctype="multipart/form-data" method="post"> 

</form> 
+0

已經添加,如果我忘了添加它,然後一個圖片項目可以上傳 – shanto