Comments (3)
요청헤더에 file_name
이 포함되어있지 않아서 그런것 같습니다.
xhr 전송전에 아래와 같이 헤더 추가해보면 되지 않을까요?
xhr.setRequestHeader("file-name",encodeURIComponent(tempFile.name));
// 전송
xhr.send(tempFile);
}
from smarteditor2.
답변주셔서 감사합니다. 말씀하신대로 추가했더니 저장은 되는데, 0kb로 빈 파일로 저장 됩니다;;
console.log로 responseText, xhr.readyState, xhr.status 찍어보면 '', 4, 200 나옵니다. 통신은 잘 되는 것 같지만 이미지는 정상적으로 저장이 되지 않아요.
그래서 //xhr.setRequestHeader("Content-Type", "multipart/form-data"); 함 추가해봤었는데, 크롬에서 CORS 발생하더라고요. 파일 자체도 아예 생성 되지 않습니다. (xhr.status: 0)
업로드가 참 .. 풀리지 않네요;;;
function callAjaxForHTML5 (tempFile, sUploadURL){
console.log('::callAjaxForHTML5::');
// IE
if (window.ActiveXObject)
xhr = new ActiveXObject("Microsoft.XMLHTTP");
// Others
else
xhr = new XMLHttpRequest();
xhr.open("POST", sUploadURL, true); //sUploadURL::https://도메인/test/smarteditor2-2.8.2.3/sample/photo_uploader/file_uploader_html5.php
xhr.withCredentials = true;
//xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.onreadystatechange = function() {
var responseText = xhr.responseText;
console.log('responseText ::' +responseText);
console.log('readyState ::' +xhr.readyState);
console.log('xhr.status ::' +xhr.status);
if (xhr.readyState == 4) {
// HTTP Status - 성공
if (xhr.status == 200) {
makeArrayFromString(responseText);
}
// HTTP Status - 실패
else {
onAjaxError();
}
}
};
// Timeout 처리
xhr.timeout = 5000;
xhr.ontimeout = function() {
onAjaxError();
};
// Form 생성
var form = new FormData();
form.append("file_name", tempFile);
// 전송
xhr.setRequestHeader("file-name",encodeURIComponent(tempFile.name));
xhr.send(form);
}
from smarteditor2.
혹시 1M 이하의 작은 사이즈이미지는 저장되나요?
만약 작은 사이즈이미지는 저장된다면 php 서버 설정값 문제일 수 있습니다.
https://stackoverflow.com/questions/21271687/file-get-contentsphp-input-returns-empty-string-with-large-files
from smarteditor2.
Related Issues (20)
- 스마트에디터에서 접기 기능을 사용할 수 있나요? HOT 1
- 내부태그 적용 안됨 HOT 1
- 네이버 입력창 contents 내용에 따라 높이(height)를 동적 조절할 수 있는 방법 있나요?
- 스마트에디터 html 부분에 스크립트 추가
- 스마트에디터 ONE 이나 3.0 버전은 외부사이트에서 사용할 수 없나요? HOT 2
- 특정 웹 영문 폰트가 SmartEditor2 에서 font-family 에 quot; 치환되는 문제발생
- textarea 내용 수정 문의 HOT 1
- 편집모드 컨트롤
- 에디터2.0 사진붙여넣기
- 네이버 스마트 에디터 2.0 이미지를 base64로 변환하여 에디터로 넣을수있나요?
- 네이버 스마트에디터 수정 시 내용을 불러오지 못함
- 스마트에디터 2.0 폐쇄망 환경 사용 문의
- react 지원여부 궁굼합니다
- 기본 글꼴 설정 관련 문의입니다.
- smarteditor2.min.js 문의
- 폰트 저작권 HOT 1
- smarteditor2 표 위치 조정 문의
- 이미지 업로드시 오류
- 이미지 퀵 업로드 시 403에러
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smarteditor2.