2011-12-08 87 views
0

我一直在尝试创建这段代码一段时间,只是想知道如果有人可能会比我更好地阅读代码,可能会发现为什么图像不会最终结束我的服务器上,因为我似乎有脑冻在这个:(从AS3和PHP的Flash网站上传图片到服务器

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; 
} 

?> 

任何帮助将是巨大的:)

+0

我没有得到任何错误消息只是UPLOADED跟踪消息。但是当我检查服务器时,没有图片! :( – WhiteFinger

+0

好吧,所以我已经从PHP中移动if语句,它创建了文件夹,但图片不在文件中:( – WhiteFinger

+0

好吧,看起来代码是如何尴尬的一直工作,只是一直是一个狡猾。我正在使用的JPEG图片,因为它只与另一个:) – WhiteFinger

回答

1

玉以及多么尴尬rassing似乎代码工作时间一直只是一个狡猾的.jpeg图片