上传具有较低上传网速的照片时出现Flash IO错误

时间:2010-03-01 22:36:39

标签: flash actionscript-2 ioerror

的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>

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

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

如何解决这个问题?

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

有关此错误的任何解决方案?

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

有时会显示套接字错误。

如果需要,我也会发布serverside php脚本。但它停在

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

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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

实际上它是一个服务器问题。几个星期前,我们使用Ubuntu 10.04和Apache移动了VDS,问题本身就消失了。

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