2012-04-21 2 views
4

클래식 ASP에서 이미지를 업로드하려고하는데 다음과 같은 코드를 사용하고 있습니다. 제대로 실행하지만 이미지가이 왜 /uploads/events/upload_img기본 ASP에서 이미지 업로드 및 디렉토리에 이미지가 없습니다.

사람이 말해 줄 수 폴더에 보이지 않는 그러나

<input type="file" name="img1" /> 

: 여기

file_path = "/uploads/events/upload_img" 
img_folder = Server.MapPath(file_path) 

Set Upload = Server.CreateObject("Persits.Upload") 
Upload.CodePage = 949 
Upload.SetMaxSize (500 * 1024), True 
Upload.OverwriteFiles = false 
Upload.CreateDirectory img_folder, True 
Upload.save 

Upload.Files("img1") 

img1을 통해 사용자로부터 촬영 한 이미지를 포함? 감사합니다

답변

1

매개 변수없이 save() 메서드를 사용하고 있기 때문에 파일은 폴더가 아니라 서버의 메모리에 업로드되고 있습니다.

이 시도 :

img_folder = Server.MapPath("/uploads/events/upload_img") 

Set Upload = Server.CreateObject("Persits.Upload") 
Upload.CodePage = 949 
Upload.SetMaxSize (500 * 1024), True 
Upload.OverwriteFiles = false 
Upload.CreateDirectory img_folder, True 
Upload.Save(img_folder) 

uploadedImg = Upload.Files("img1") 

다음은 Persits.Upload 객체 참조의 Save() method에 대한 링크입니다.

+1

이 함수의 상대 경로를 절대 경로로 변환하려면 'Server.MapPath'가 필요합니다. 상대 경로로 작업하려면'Upload.SaveVirtual'을 사용하십시오. –

0

아래 코드가 작동합니다. 멀티 파트 양식으로 게시하십시오.

========================= 
EXAMPLE MULTIPART FORM 
========================= 

<form method="post" enctype="multipart/form-data" action=""> 
<input type="file" name="img1" /><input type="submit" /> 
</form> 

========= 
ASP CODE 
========= 

Set Upload = Server.CreateObject("Persits.Upload") 
Upload.CodePage = 949    
Upload.SetMaxSize (500 * 1024), True 
Upload.OverwriteFiles = False ' Generate unique names 
Upload.Save "C:\path\filename.jpg" 

Set File = Upload.Files(1) 
uploadedImg = File.ExtractFileName 

Set Upload = Nothing 
Set File = Nothing 
관련 문제