在上传网速较低的情况下上传照片时出现 Flash IO 错误

发布于 2024-08-23 08:47:20 字数 6167 浏览 4 评论 0原文

动作脚本:

System.security.allowDomain("http://" + _root.tdomain + "/");
import flash.net.FileReferenceList;
import flash.net.FileReference;
import flash.external.ExternalInterface;
import flash.external.*;

/* Main variables */
var session_photos = _root.ph;
var how_much_you_can_upload = 0;

var selected_photos; // container for selected photos
var inside_photo_num = 0; // for photo in_array selection
var created_elements = _root.ph;
var for_js_num = _root.ph;




/* Functions & settings for javascript<->flash conversation */
var methodName:String = "addtoflash";
var instance:Object = null;
var method:Function = addnewphotonumber;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
function addnewphotonumber() {
 session_photos--;
 created_elements--;
 for_js_num--;
}

/* Javascript hide and show flash button functions */
function block(){getURL("Javascript: blocking();");}
function unblock(){getURL("Javascript:unblocking();");}

/* Creating HTML platform function */
var result = false;




/* Uploading */
function uploadthis(photos:Array) {

 if(!photos[inside_photo_num].upload("http://" + _root.tdomain + "/upload.php?PHPSESSID=" + _root.phpsessionid)) 
 {
  getURL("Javascript:error_uploading();");
 }
}




/* Flash button(applet) options and bindings */
var fileTypes:Array = new Array();
var imageTypes:Object = new Object();
imageTypes.description = "Images (*.jpg)";
imageTypes.extension = "*.jpg;";
fileTypes.push(imageTypes);

var fileListener:Object = new Object();
var btnListener:Object = new Object();
btnListener.click = function(eventObj:Object)
{
 var fileRef:FileReferenceList = new FileReferenceList();
 fileRef.addListener(fileListener);
 fileRef.browse(fileTypes);
}
uploadButton.addEventListener("click", btnListener);














/* Listeners */
fileListener.onSelect = function(fileRefList:FileReferenceList):Void
 {
  // reseting values
  inside_photo_num = 0;

  var list:Array = fileRefList.fileList;
  var item:FileReference;

  // PHP photo counter
  how_much_you_can_upload = 3 - session_photos;

  if(list.length > how_much_you_can_upload)
  {
   getURL("Javascript:howmuch=" + how_much_you_can_upload + ";list_length=" + list.length + ";limit_reached();");
   return;
  }

  // if session variable isn't yet refreshed, we check inner counter
  if(created_elements >= 3)
  {
   getURL("Javascript:limit_reached();");
   return;
  }

 selected_photos = list;

 for(var i:Number = 0; i < list.length; i++)
  {
   how_much_you_can_upload--;
   item = list[i];
   trace("name: " + item.name);
   trace(item.addListener(this));
   if((item.size / 1024) > 5000) {getURL("Javascript:size_limit_reached();");return;}   
  }

  result = false;
  setTimeout(block,500);

  /* Increment number for new HTML container and pass it to javascript, after javascript returns true and we start uploading */
  for_js_num++;
  if(ExternalInterface.call("create_platform",for_js_num))
  {
   uploadthis(selected_photos);
  }




 }


fileListener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void
{
 getURL("Javascript:files_process(" + bytesLoaded + "," + bytesTotal + "," + for_js_num + ");");
}

fileListener.onComplete = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void
{
 inside_photo_num++;

 var sendvar_lv:LoadVars = new LoadVars();
 var loadvar_lv:LoadVars = new LoadVars();
 loadvar_lv.onLoad = function(success:Boolean){

  if(loadvar_lv.failed == 1) {
  getURL("Javascript:type_failed();");
  return;
  }

  getURL("Javascript:filelinks='" + loadvar_lv.json + "';fullname='" + loadvar_lv.fullname + "';completed(" + for_js_num + ");");

  created_elements++;

  if((inside_photo_num + 1) > selected_photos.length) {setTimeout(unblock,1000);return;} // don't create empty containers anymore  
  if(created_elements >= 3) {return;}

  result = false;

  /* Increment number for new HTML container and pass it to javascript, after javascript returns true and we start uploading */
  for_js_num++;
  if(ExternalInterface.call("create_platform",for_js_num))
  {
   uploadthis(selected_photos);
  }
 }
 sendvar_lv.getnum = true;
 sendvar_lv.PHPSESSID = _root.phpsessionid;
 sendvar_lv.sendAndLoad("http://" + _root.tdomain + "/upload.php",loadvar_lv,"POST");    

}








fileListener.onCancel = function(file:FileReference):Void
{
}

fileListener.onOpen = function(file:FileReference):Void
{
}

fileListener.onHTTPError = function(file:FileReference, httpError:Number):Void
{
 getURL("Javascript:http_error(" + httpError + ");");
}

fileListener.onSecurityError = function(file:FileReference, errorString:String):Void
{
 getURL("Javascript:security_error(" + errorString + ");");
}

fileListener.onIOError = function(file:FileReference):Void
{
 getURL("Javascript:io_error();");
 selected_photos[inside_photo_num].cancel();
 uploadthis(selected_photos); 
}

<PARAM name="allowScriptAccess" value="always">
<PARAM name="swliveconnect" value="true">
<PARAM name="movie" value="http://www.localh.com/fileref.swf?ph=0&phpsessionid=8mirsjsd75v6vk583vkus50qbb2djsp6&tdomain=www.localh.com">
<PARAM name="wmode" value="opaque">
<PARAM name="quality" value="high">
<PARAM name="bgcolor" value="#ffffff">
<EMBED swliveconnect="true" wmode="opaque" src="http://www.localh.com/fileref.swf?ph=0&phpsessionid=8mirsjsd75v6vk583vkus50qbb2djsp6&tdomain=www.localh.com" quality="high" bgcolor="#ffffff" width="100" height="22" name="fileref" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></EMBED>

我的上传速度是40kb/秒 上传大于500kb的照片时出现flash错误,上传小于100-500kb的照片时没有错误~。

我的朋友有 8mbit 的上传速度,即使上传 3.2mb 的照片等也没有错误。

如何解决这个问题?

我尝试在 IO 错误触发时重新上传,但它停止在同一个地方。

关于这个错误有什么解决办法吗?

顺便说一句,我通过调试代理观察进程并发现,响应标头根本不会出现在这个 IO 错误上。

有时会显示套接字错误。

如果需要,我也会发布服务器端 php 脚本。但它停止在

if(isset($_FILES['Filedata']))
{

所以它不会有帮助:)因为所有处理都在此检查之后进行。

Actionscript:

System.security.allowDomain("http://" + _root.tdomain + "/");
import flash.net.FileReferenceList;
import flash.net.FileReference;
import flash.external.ExternalInterface;
import flash.external.*;

/* Main variables */
var session_photos = _root.ph;
var how_much_you_can_upload = 0;

var selected_photos; // container for selected photos
var inside_photo_num = 0; // for photo in_array selection
var created_elements = _root.ph;
var for_js_num = _root.ph;




/* Functions & settings for javascript<->flash conversation */
var methodName:String = "addtoflash";
var instance:Object = null;
var method:Function = addnewphotonumber;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
function addnewphotonumber() {
 session_photos--;
 created_elements--;
 for_js_num--;
}

/* Javascript hide and show flash button functions */
function block(){getURL("Javascript: blocking();");}
function unblock(){getURL("Javascript:unblocking();");}

/* Creating HTML platform function */
var result = false;




/* Uploading */
function uploadthis(photos:Array) {

 if(!photos[inside_photo_num].upload("http://" + _root.tdomain + "/upload.php?PHPSESSID=" + _root.phpsessionid)) 
 {
  getURL("Javascript:error_uploading();");
 }
}




/* Flash button(applet) options and bindings */
var fileTypes:Array = new Array();
var imageTypes:Object = new Object();
imageTypes.description = "Images (*.jpg)";
imageTypes.extension = "*.jpg;";
fileTypes.push(imageTypes);

var fileListener:Object = new Object();
var btnListener:Object = new Object();
btnListener.click = function(eventObj:Object)
{
 var fileRef:FileReferenceList = new FileReferenceList();
 fileRef.addListener(fileListener);
 fileRef.browse(fileTypes);
}
uploadButton.addEventListener("click", btnListener);














/* Listeners */
fileListener.onSelect = function(fileRefList:FileReferenceList):Void
 {
  // reseting values
  inside_photo_num = 0;

  var list:Array = fileRefList.fileList;
  var item:FileReference;

  // PHP photo counter
  how_much_you_can_upload = 3 - session_photos;

  if(list.length > how_much_you_can_upload)
  {
   getURL("Javascript:howmuch=" + how_much_you_can_upload + ";list_length=" + list.length + ";limit_reached();");
   return;
  }

  // if session variable isn't yet refreshed, we check inner counter
  if(created_elements >= 3)
  {
   getURL("Javascript:limit_reached();");
   return;
  }

 selected_photos = list;

 for(var i:Number = 0; i < list.length; i++)
  {
   how_much_you_can_upload--;
   item = list[i];
   trace("name: " + item.name);
   trace(item.addListener(this));
   if((item.size / 1024) > 5000) {getURL("Javascript:size_limit_reached();");return;}   
  }

  result = false;
  setTimeout(block,500);

  /* Increment number for new HTML container and pass it to javascript, after javascript returns true and we start uploading */
  for_js_num++;
  if(ExternalInterface.call("create_platform",for_js_num))
  {
   uploadthis(selected_photos);
  }




 }


fileListener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void
{
 getURL("Javascript:files_process(" + bytesLoaded + "," + bytesTotal + "," + for_js_num + ");");
}

fileListener.onComplete = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void
{
 inside_photo_num++;

 var sendvar_lv:LoadVars = new LoadVars();
 var loadvar_lv:LoadVars = new LoadVars();
 loadvar_lv.onLoad = function(success:Boolean){

  if(loadvar_lv.failed == 1) {
  getURL("Javascript:type_failed();");
  return;
  }

  getURL("Javascript:filelinks='" + loadvar_lv.json + "';fullname='" + loadvar_lv.fullname + "';completed(" + for_js_num + ");");

  created_elements++;

  if((inside_photo_num + 1) > selected_photos.length) {setTimeout(unblock,1000);return;} // don't create empty containers anymore  
  if(created_elements >= 3) {return;}

  result = false;

  /* Increment number for new HTML container and pass it to javascript, after javascript returns true and we start uploading */
  for_js_num++;
  if(ExternalInterface.call("create_platform",for_js_num))
  {
   uploadthis(selected_photos);
  }
 }
 sendvar_lv.getnum = true;
 sendvar_lv.PHPSESSID = _root.phpsessionid;
 sendvar_lv.sendAndLoad("http://" + _root.tdomain + "/upload.php",loadvar_lv,"POST");    

}








fileListener.onCancel = function(file:FileReference):Void
{
}

fileListener.onOpen = function(file:FileReference):Void
{
}

fileListener.onHTTPError = function(file:FileReference, httpError:Number):Void
{
 getURL("Javascript:http_error(" + httpError + ");");
}

fileListener.onSecurityError = function(file:FileReference, errorString:String):Void
{
 getURL("Javascript:security_error(" + errorString + ");");
}

fileListener.onIOError = function(file:FileReference):Void
{
 getURL("Javascript:io_error();");
 selected_photos[inside_photo_num].cancel();
 uploadthis(selected_photos); 
}

<PARAM name="allowScriptAccess" value="always">
<PARAM name="swliveconnect" value="true">
<PARAM name="movie" value="http://www.localh.com/fileref.swf?ph=0&phpsessionid=8mirsjsd75v6vk583vkus50qbb2djsp6&tdomain=www.localh.com">
<PARAM name="wmode" value="opaque">
<PARAM name="quality" value="high">
<PARAM name="bgcolor" value="#ffffff">
<EMBED swliveconnect="true" wmode="opaque" src="http://www.localh.com/fileref.swf?ph=0&phpsessionid=8mirsjsd75v6vk583vkus50qbb2djsp6&tdomain=www.localh.com" quality="high" bgcolor="#ffffff" width="100" height="22" name="fileref" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></EMBED>

My uploading speed is 40kb/sec
Getting flash error while uploading photos bigger than 500kb and getting no error while uploading photos less than 100-500kb~.

My friend has 8mbit uploading speed and has no errors even while uploading 3.2mb photos and more.

How to fix this problem?

I have tried to re-upload on IO error trigger, but it stops at the same place.

Any solution regarding this error?

By the way, i was watching process via debugging proxy and figured out, that responce headers doesn't come at all on this IO error.

And sometimes shows socket error.

If need, i will post serverside php script as well. But it stops at

if(isset($_FILES['Filedata']))
{

so it won't help :) as all processing comes after this check.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白日梦 2024-08-30 08:47:20

听起来像是服务器的问题,而不是动作脚本的问题。尝试更新 php.ini 以允许更大的上传限制:
http://www.radinks.com/upload/config.php

Sounds like a problem with the server, not so much in the actionscript. Try updating the php.ini to allow larger upload limits:
http://www.radinks.com/upload/config.php

述情 2024-08-30 08:47:20

实际上这是服务器问题。几周前,我们在带有 Apache 的 Ubuntu 10.04 上迁移到 VDS,问题自行消失了。

我记得在以前的服务器上,有带有unix的litespeed服务器。

Actually it WAS a server problem. A few weeks ago we moved on VDS with Ubuntu 10.04 with Apache and the problem disappeared by itself.

On previous server, there were litespeed server with unix as I remember.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文