Photoshop API公开套接字对象.你可以像这样使用它
function sendDataToServer(data) {
var socket = new Socket(),
port = 80,
domain = "www.example.com",
page = "/path/to/file.php",
bin;
if(socket.open(domain + ":" + port,"binary")) {
socket.write("GET http://" + domain + page + "?data=" + data + " HTTP/1.0\n\n");
bin = socket.read(9999999);
alert(bin);
socket.close();
}
}
Run Code Online (Sandbox Code Playgroud)
这将返回服务器响应以及请求的标头.您可以使用以下方法读取文件:
function getLine(html){
var line = "", i = 0;
for (; html.charCodeAt(i) != 10; i++){ // finding line end
line += html[i] ;
}
return line;
}
Run Code Online (Sandbox Code Playgroud)
此方法还将使用以下getLine方法剥离标头:
function removeHeaders(binary){
var bContinue = true, // flag for finding end of header
line = "",
nFirst = 0,
count = 0;
while (bContinue) {
line = getLine(binary) ; // each header line
bContinue = line.length >= 2 ; // blank header == end of header
nFirst = line.length + 1 ;
binary = binary.substr(nFirst) ;
}
return binary;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2495 次 |
| 最近记录: |