2012-05-11 17 views
2

uploadifyでファイルをアップロードするときに500エラーが発生します。私は間違っているかもしれないのかわからない...Uploadify 3.1とMVC 3.0 HTTP 500エラー

jQuery(document).ready(function() { 
    jQuery("#file_upload").uploadify({ 
     'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")', 
     'buttonText': 'Browse Files', 
     'uploader': '@Url.Action("upload", "upload")', 
     'debug': true, 
     'fileObjName': 'file', 
     // 'scriptData': { 'fname':$("#fname").val(), 'fname2':fname}, 
     'fileSizeLimit': '38000000', 
     'multi': true, 
     'auto': true, 
     'onUploadError' : function(file, errorCode, errorMsg, errorString) { 
      alert('The file ' + file.name + ' could not be uploaded: ' + errorString) 
     }, 
     onAllComplete: function (event, queueID, fileObj, response, data) { 
      alert(response); 

     } 
    }); 
}); 

//コントローラー:

[HttpPost] 
     public ActionResult Upload(HttpPostedFileBase file) 
     { 



      var fileName = Path.GetFileName(file.FileName); 
      file.SaveAs("D:\\inetpub\\wwwroot\\RTDOTNETMEMBER\\audio\\songs\\mp3\\" + fileName); 
      return Content(fileName); 

     } 

デバッグファイル:

---SWFUpload Instance Info--- 
Version: 2.2.0 2009-03-25 
Movie Name: SWFUpload_0 
Settings: 
    upload_url:    /upload/upload 
    flash_url:    /Content/uploadify/uploadify.swf?preventswfcaching=1336720242632 
    use_query_string:   false 
    requeue_on_error:   false 
    http_success:    
    assume_success_timeout: 30 
    file_post_name:   file 
    post_params:    [object Object] 
    file_types:    *.* 
    file_types_description: All Files 
    file_size_limit:   38000000 
    file_upload_limit:  0 
    file_queue_limit:   999 
    debug:     true 
    prevent_swf_caching:  true 
    button_placeholder_id: file_upload 
    button_placeholder:  Not Set 
    button_image_url:   /Song/ 
    button_width:    120 
    button_height:   30 
    button_text:    
    button_text_style:  color: #000000; font-size: 16pt; 
    button_text_top_padding: 0 
    button_text_left_padding: 0 
    button_action:   -110 
    button_disabled:   false 
    custom_settings:   [object Object] 
Event Handlers: 
    swfupload_loaded_handler assigned: false 
    file_dialog_start_handler assigned: true 
    file_queued_handler assigned:  true 
    file_queue_error_handler assigned: true 
    upload_start_handler assigned:  true 
    upload_progress_handler assigned: true 
    upload_error_handler assigned:  true 
    upload_success_handler assigned: true 
    upload_complete_handler assigned: true 
    debug_handler assigned:    true 

SWF DEBUG: SWFUpload Init Complete 
SWF DEBUG: 
SWF DEBUG: ----- SWF DEBUG OUTPUT ---- 
SWF DEBUG: Build Number:   SWFUPLOAD 2.2.0 
SWF DEBUG: movieName:    SWFUpload_0 
SWF DEBUG: Upload URL:    /upload/upload 
SWF DEBUG: File Types String:  *.* 
SWF DEBUG: Parsed File Types:  
SWF DEBUG: HTTP Success:   0 
SWF DEBUG: File Types Description: All Files (*.*) 
SWF DEBUG: File Size Limit:  38912000000 bytes 
SWF DEBUG: File Upload Limit:  0 
SWF DEBUG: File Queue Limit:  999 
SWF DEBUG: Post Params: 
SWF DEBUG: ----- END SWF DEBUG OUTPUT ---- 
SWF DEBUG: 
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.* 
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list... 
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0 
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1 
SWF DEBUG: StartUpload: First file in queue 
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0 
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to /upload/upload for File ID: SWFUpload_0_0 
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0 
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 3545865. Total: 3545865 
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 500. 
SWF DEBUG: Event: uploadComplete : Upload cycle complete. 
SWF DEBUG: Event: AssumeSuccess: 30 passed without server response 
+0

あなたは、デバッグおよび例外で見たことがありますか?ファイルの大きさはどれくらいですか? –

+0

約100kbの小さな.jpgです。私はデバッグファイルを投稿します。 – user547794

答えて

3

次のスイッチを追加します。

fileDataName: 'file' 

また、が混在しているようですおよびuploader引数。

jQuery(document).ready(function() { 
    jQuery("#file_upload").uploadify({ 
     uploader: '@Url.Content("~/Content/uploadify/uploadify.swf")', 
     script: '@Url.Action("upload", "upload")', 
     fileDataName: 'file', 
     sizeLimit: 38000000, 
     cancelImg: '@Url.Content("~/Content/uploadify/cancel.png")', 
     auto: true, 
     debug: true, 
     onError: function() { 
      alert('some error occurred. Sorry'); 
     }, 
     onComplete: function (event, queueId, fileObj, response, data) { 
      alert(response); 
     } 
    }); 
}); 

と、サーバー上:次のように試してみてください

[HttpPost] 
public ActionResult Upload(HttpPostedFileBase file) 
{ 
    if (file != null && file.ContentLength > 0) 
    { 
     // TODO: storing uploaded files to the App_Data folder on the server. 
     // Adjust this location to fit your requirements 
     var appData = Server.MapPath("~/app_data"); 
     var filename = Path.Combine(appData, Path.GetFileName(file.FileName)); 
     file.SaveAs(filename); 
    } 
    return Json(true); 
} 
+0

ありがとう、私の問題はサーバー側のコードにあったようです。私はあなたのものと交換し、それは素晴らしい仕事をしました。私は新しい3.1バージョンを使用しており、ドキュメントによれば、jsのパラメータのいくつかはもう動作しません。 – user547794

+0

この郵便が問題の解決に役立った場合は、[回答としてマークする](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)をクリックすることを検討する必要がありますその隣のティックに。 –

+0

swf(now swf)とアップロードハンドラ(now uploader)のパラメータは、uploadifyのバージョン3で変更されています。 –