3초기억력

ajax 이미지 업로드 본문

코딩_jquery

ajax 이미지 업로드

잠수콩 2015. 6. 30. 10:20
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



제목 :  ajax 이미지 업로드


소스 :


<script src="/jscript/ajaxfileupload.js"></script>
  <script>
  function imgUpload()
 {
   $('input:radio[name="basic_pic"]').attr("checked", false);
   $("#p_img").html('')
   $("#profile_img").val('');

   $.ajaxFileUpload
   (
    {
     url:'/member/profile_upload.asp',
     secureuri:false,
     fileElementId:"thumb",
     dataType: 'json',

     success: function (data, status)
     {

      var result = data.msg;
      strhtml="<img src='/data/rental/profile/"+result+" ' border='0' width='100px' height='100px' />";
      $("#p_img").html(strhtml)
      $("#profile_img").val(result);
      return;

     },
     error: function (data, status, e)
     {
      alert(data.error);
     }
    }
   )
 }
  </script>

 

------------------------------

>>member/profile_upload.asp 파일 소스

 

<!--#include virtual="/_include/config.asp"-->
<!--#include virtual="/_lib/function.File.asp"-->
<%
Call defineUpload

thumb_folder = pathBase&"/rental/profile"

thumb = getUploadItem("thumb")

Ext=getFileExt(thumb,false)

filename=Replace(date(),"-","")&rndomstring(10)&"."&ext

if ext<>lcase("jpeg") and ext<>lcase("jpg") and ext<>lcase("gif") and ext<>lcase("bmp") and ext<>lcase("png") then
 response.write  "{error:""ext""}"
 response.end
end if

Call fileUpload("thumb",thumb_folder , filename, sPath, sFilename, sSize)


if Err.Number <> 0 then  '//에러
 result = "error"
 response.write  "{error:""error""}"
else
 response.write "{msg:"""&filename&"""}"
end if

function rndomstring(cnt)
 Dim str,cntArr,flg,tStr
 str=""
 Randomize()
 for cntArr=1 to cnt
 flg=Int(Rnd()*10)
 if flg>5 then
  tStr=Int(Rnd()*10)
 else
  tStr=Int(Rnd()*26)
  tStr=Chr(asc("a")+tStr)
 end if
 str = str & tStr
 next
 rndomstring=str
end Function
%>


 


내용 :



예제 소스 파일 :

ajaxfileupload.js

 


 출처 :  


 

Comments