繁体   English   中英

从AS3和PHP中的Flash网站将图像上传到服务器

[英]Uploading images to server from a flash web site in AS3 and PHP

我一直在尝试创建此代码一段时间,只是想知道是否有人比我能读得更好的代码可能会弄清楚为什么图像无法最终显示在我的服务器上,因为我似乎对此不动了:(

var fileRef:FileReference = new FileReference(); 
fileRef.addEventListener(Event.SELECT, selectHandler); 
fileRef.addEventListener(Event.COMPLETE, completeHandler); 
try 
{ 
var success:Boolean = fileRef.browse(); 
} 
catch (error:Error) 
{ 
trace("Unable to browse for files."); 
} 
function selectHandler(event:Event):void 
{ 
var request:URLRequest = new URLRequest("http://localhost/upload.php") 
try 
{ 
fileRef.upload(request); 
} 
catch (error:Error) 
{ 
trace("Unable to upload file."); 
} 
} 
function completeHandler(event:Event):void 
{ 
trace("uploaded"); 
}
customerService.createClients(SlagsData);
}

然后这是服务器上的php

<?php
define('UPLOAD_DIR', 'c:/wamp/www/IMAGES/');
define('UPLOAD_DIR_default', 'c:/wamp/www/IMAGES/0/image01.jpg');
$hostname_thatexclients = "localhost";
$database_thatexclients = "myexclients";
$username_thatexclients = "root";
$password_thatexclients = "";
$thatexclients = mysql_connect($hostname_thatexclients, $username_thatexclients,   $password_thatexclients) or trigger_error(mysql_error(),E_USER_ERROR); 
set_time_limit ( 240 );




if($_FILES['yourpic']['size'] > 1) 
{
if($_FILES['yourpic']['size'] < 5000000) 
$newname = "image01.jpg";
$id = 0;
$query = ("SELECT * FROM clients WHERE  ID = (SELECT MAX(ID) FROM clients)") or die(mysql_error());
mysql_select_db($database_thatexclients, $thatexclients);
$Result2 = mysql_query($query, $thatexclients) or die(mysql_error());
While($row = mysql_fetch_array($Result2))
{
$id = $row["ID"];
$id = ($id + "1");
}  
mkdir(UPLOAD_DIR.$id, 0777, true) or die ("Could not make directory"); 
$idr = ($id.'/');  
move_uploaded_file($_FILES['yourpic']['tmp_name'],UPLOAD_DIR.$idr .$newname);// this one works  
}
else
{
$id = 0;
}

?>

任何帮助将是巨大的:)

好吧,代码必须一直是狡猾的.jpeg图片,代码看起来一直在令人尴尬地工作着

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM