2012-01-06 5 views
0

를 통해 업로드 이미지 나 이미지를 http://www.finalwebsites.com/demos/php_ajax_upload_example.phpJQuery와 아약스, 아약스

을 업로드하는이 플러그인을 사용하고 있습니다하지만이 작동하지 않습니다. 오류가 발생하지만 즉시 방화범이 든다.

어떻게 작동시킬 수 있습니까? 아무도 jsfiddle에서 작동하는 플러그인을 보여줄 수 있습니까?

미리 감사드립니다.

+0

어떻게 우리가 뭐가 잘못 됐는지 확인하고 문제를 해결할 수 있도록 먼저 비 작업 스크립트와 jsfiddle을 제공 어떻습니까? –

+0

우리에게 플러그인을 사용하는 방법 –

+1

오류없이 또는 심지어 코드를 진단하지 않으면 불가능할 것입니다. 플러그인 링크에는 예제 코드가 있습니다 -이 코드는이 코드와 일치합니까? –

답변

0

플러그인이나 아약스로 파일을 업로드하는 방법에 대해 알지 못합니다. 그러나 이것은 내가 인터넷 검색을 한 후에 비슷한 것을 성취 한 방법입니다.

1)는 업로드를 처리하는 일부 jQuery를하다) 어딘가 페이지에

<div id="iframeholder" style="height:0px;width:0px;display:none;"></div> 

2 사업부를 넣습니다. div에 iframe을 추가하고 양식 제출의 대상으로 설정합니다. 그런 다음 iframe의 내용을 읽어 업로드 결과를 볼 수 있습니다.

thefile = $('#myfileinput').val(); 
    iframe = $('<iframe name="theiframe" id="theiframe"></iframe>'); 
    $('#iframeholder').append(iframe); 
    $('#theuploadform').attr("action","save.php"); 
    $('#theuploadform').attr("method","post"); 
    $('#theuploadform').attr("thefile",thefile); 
    $('#theuploadform').attr("enctype","multipart/form-data"); 
    $('#theuploadform').attr("encoding","multipart/form-data"); 
    $('#theuploadform').attr("target","theiframe"); 
    $('#theuploadform').submit(); 
    $("#theiframe").load(function() { 
    iframeContents = $('#theiframe').contents().find('body').html(); 
    $('#theiframe').remove(); 
    } 

3)이 나의 가장 자랑스러운 순간이 아니라 당신이 사용자 프레스 당신이 키를 누를 경우 확인하여 할 수있는 입력 필드에 입력 할 때 자체에 제출 양식을 방지 할 필요가 입력 한 후 국한 다른 어떤 통제. 선택기를 여기에서 필요에 맞게 선택하십시오.

$('input[type=text]').bind("keypress", function(thekey) { 
    if(thekey.which == "13") { $('#someothercontrol').focus();return false; } 
    });