2013-01-09 2 views
1

파일을 업로드 할 양식이있는 대화 상자를 표시합니다.jquery로 PHP를 통해 파일을 업로드하려면 어떻게해야합니까?

확인을 클릭하면 선택한 파일이 업로드됩니다.

jquery와 PHP로 어떻게 할 수 있습니까?

코드 :

if(act=='exchangePic') 
{    
    $("#dialog").attr('title','Change picture ').dialog({buttons:{'ok':{class:'btn',text:'Ok',click:function(){ 
    $('#imgHolder_'+picture_id).css({'background-color':''}); 
    $(this).dialog('close');  

    }}}, show:'fade',hide:'explode',width:'380px',modal:true,closeText:' X '}).html("<form><input type='file' id='newUpload' name='newUpload' class='upfile'/></form>"); 

}//end of act=='exchangePic' 
+1

입니다. @Blueimp.github.com/jQuery-File-Upload/ – Arun

+4

@Arunkumar를 사용해보십시오. 가능합니다. File API를 지원하는 브라우저 만 있으면됩니다. 예 : https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications#Example.3A_Uploading_a_user-selected_file – Quentin

+0

@Arunkumar, XMLHttpRequest v 2.0은 파일을 처리 할 수 ​​있습니다. 원하는 경우 jQuery 양식 플러그인을 사용할 수도 있습니다. 정말 간단합니다. http://malsup.com/jquery/form/ – MahanGM

답변

1

왜 모든 것을 직접 작성? Plupload은 많은 훌륭한 기능이있는 고체 open source uploader입니다. 여기

당신은 XMLHttpRequest의 (AJAX)을 사용하여 파일을 업로드 할 수 jquery sample

Plupload features

+0

감사합니다. 나는 그것을 지금 시도 할 것이다. –

관련 문제