2012-04-01 18 views
0

私はこれで既に1時間30分で戦っていますが、問題は見つかりません。私はCodeIgniterのアップロード機能を使用していますが、それは常にアップロードに失敗する -codeigniterにアップロードされた画像がありません

コントローラ -

// Uploads the picture to server 
    public function uploadPicture() 
    { 
    $this->load->helper(array('form', 'url')); 
    $this->load->helper('url'); 
     $config['upload_path'] = './images/pictures/'; 
     $config['allowed_types'] = 'gif|jpg|png'; 
     $config['max_size'] = '700'; 
     $config['max_width'] = '1024'; 
     $config['max_height'] = '768'; 

     $this->load->library('upload', $config); 

     $this->upload->do_upload(); 

     if (! $this->upload->do_upload()) 
     { 
      $data = array('upload_data' => $this->upload->data());  

      var_dump($data); 
     //redirect('/profile/changePicture', 'refresh'); 
     } 
     else 
     { 
     redirect('/profile/changePicture', 'refresh');    
     } 
    } 

ビュー -

私が選択した場合、私はどちらか何の画像を選択していない、または後
<form class="fix-this form" method="post" action="/savieno/profile/uploadPicture" enctype="multipart/form-data"> 
        <div class="formfield">      
         <label id="current-password-error" class="input-error" style="display: none;"></label>   
         <span class="profile">Tava bilde: </span>         
         <input id="picture" name="picture" class="with-label" style="width: 270px;" type="file" placeholder="Tava bilde" /> 
         <label>*</label> 
    </div>      
        <input type="submit" id="submit" value="Labot Profilu" name="edit" class="fix-this" />   
    </form> 

画像、それは私にdetialsとvar_dumpを与える -

array 
    'upload_data' => 
    array 
     'file_name' => string '' (length=0) 
     'file_type' => string '' (length=0) 
     'file_path' => string './images/pictures/' (length=18) 
     'full_path' => string './images/pictures/' (length=18) 
     'raw_name' => string '' (length=0) 
     'orig_name' => string '' (length=0) 
     'client_name' => string '' (length=0) 
     'file_ext' => string '' (length=0) 
     'file_size' => string '' (length=0) 
     'is_image' => boolean false 
     'image_width' => string '' (length=0) 
     'image_height' => string '' (length=0) 
     'image_type' => string '' (length=0) 
     'image_size_str' => string '' (length=0) 

何が問題だろうか?

+0

それはどのように失敗するのか?何が起こるのですか?間違いはありますか? – kba

+0

いいえエラーはありません。単にvar_dumpをロードします。コントローラーを確認します。アップロードに失敗した場合は、var_dumpをロードします。それ以外の場合はリダイレクトします。 ;/ –

+0

あなたは '$ this-> upload-> do_upload()'を2回行っています。 – kba

答えて

0

$config['upload_path'] = './images/pictures/';あなたが書き込むパスが正しいことと、ファイルを書き込む権利が適切であることを確認してください。

また、クリスチャンが書いたように、$this->upload->do_upload();アップロード部分を2回実行しています。

がエラーをチェックするために、あなたはこれを行うことができます。

<?php 
if(!$this->upload->do_upload())   
{ 
    echo $this->upload->display_error(); 
    return FALSE; 
} 
else 
{ 
    $data = $this->upload->data(); 
    return TRUE; 
} 
+0

ああ、ええ、私はそれが何らかのエラーを出すかどうかをチェックするだけであったが、それはわかりません。ローカルホストにいる場合は、2回チェックしてみてください。http:// localhost/images/pictures /の完全な部分をwrtieできますか?さらに、localhostでチェックしているのであれば、本当にパーミッションを設定する必要がありますか? –

+0

テストする場所には、アクセス許可を設定する必要があります。単にCIプロジェクトのメインフォルダに 'uploads'フォルダを作成し、権限を設定してやり直すことができます。 –

+0

ええと、どうすればlocalhostに権限を設定できますか? :P私はWindows 7を使用していますが、localhostにサーバを設定していないので、サーバを設定してからfilezilla経由で接続する必要がありますか? –

関連する問題