2011-04-14 8 views
1

私は現在、画像をアップロードして切り抜くためにその画像の領域を選択できるサイトの一部をコーディングしています。私はそのイメージがフォームを提出しなくてもアップロードできるようにしたいのでswfuploadというツールを使ってイメージをアップロードすることができましたが、swfuploadを使ってサムネイルを作成したり、サムネイル方式。以下は codeigniter imageアップロードとサイズ変更 - swfupload

は私のコード、

PHP

public function upload() 
    { 
     $config['upload_path'] = "./media/uploads/users"; 
     $config['allowed_types'] = 'gif|jpg|png'; 
     $config['max_size'] = '1000'; 
     $config['max_width'] = '1024'; 
     $config['max_height'] = '768'; 
     $config['encrypt_name'] = TRUE; 

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


     if (! $this->upload->do_upload('Filedata')) 
     { 
      $error = array('error' => $this->upload->display_errors()); 
      //die(print_r($error)); 
     } 
     else 
     { 
      $this->file = $this->upload->data(); 
      echo $this->file['file_name']; 
     } 
    } 

    public function thumbnail() 
    { 
       //lets just try and get thumbnail() talking to swfupload 
     echo 1; 
    } 

SWFUploadのJS

window.onload = function() { 
      swfu = new SWFUpload({ 
       // Backend Settings 
       upload_url: "http://lcl.moovjob.com/index.php/admin/users/upload", 
       post_params: {"PHPSESSID": "<?php echo $this->session->userdata('session_id'); ?>" }, 

       // File Upload Settings 
       file_size_limit : "5 MB", // 5MB 
       file_types : "*.jpg", 
       file_types_description : "JPG Images", 
       file_upload_limit : "0", 

       // Event Handler Settings - these functions as defined in Handlers.js 
       // The handlers are not part of SWFUpload but are part of my website and control how 
       // my website reacts to the SWFUpload events. 
       file_queue_error_handler : fileQueueError, 
       file_dialog_complete_handler : fileDialogComplete, 
       upload_progress_handler : uploadProgress, 
       upload_error_handler : uploadError, 
       upload_success_handler : uploadSuccess, 
       upload_complete_handler : uploadComplete, 

       // Button Settings 
       button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png", 
       button_placeholder_id : "spanButtonPlaceholder", 
       button_width: 180, 
       button_height: 18, 
       button_text : '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>', 
       button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }', 
       button_text_top_padding: 0, 
       button_text_left_padding: 18, 
       button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, 
       button_cursor: SWFUpload.CURSOR.HAND, 

       // Flash Settings 
       flash_url : "/media/flash/swfupload.swf", 

       custom_settings : { 
        upload_target : "divFileProgressContainer" 
       }, 

       // Debug Settings 
       debug: true 
      }); 
     }; 

マイハンドラJS

、特にアップロードの成功法、

function uploadSuccess(file, serverData) { 
    try { 
     var progress = new FileProgress(file, this.customSettings.upload_target); 

     if (serverData.substring(0, 7) === "FILEID:") { 
      addImage("http://local.test.com/index.php/admin/users/thumbnail"); 

      progress.setStatus("Thumbnail Created."); 
      progress.toggleCancel(false); 
     } else { 
      addImage("images/error.gif"); 
      progress.setStatus("Error."); 
      progress.toggleCancel(false); 
      alert(serverData); 

     } 


    } catch (ex) { 
     this.debug(ex); 
    } 
} 

何午前です私は私がswfuploadが私のコントローラに話していることを知っているので、画像がアップロードされてから1を返すことを私がしたいのです。私が戻ってくるのは、アップロードの成功またはエラーです。

答えて

0

なぜアップロード機能の最後にサムネイルを追加しないのですか?私が考える限り、これらの操作を別々に行う必要はありません。

アップロード機能で正常にアップロードされたことを確認しているので、データを返す前に、ファイル名/ dirをサムネイル関数に渡し、サムネイルを作成して成功または失敗を返します。

関連する問題