【问题标题】:Uploading images to server from a flash web site in AS3 and PHP在 AS3 和 PHP 中从 Flash 网站上传图像到服务器
【发布时间】:2011-12-08 12:11:29
【问题描述】:

我一直在尝试创建此代码一段时间,只是想知道是否有人可能比我更好地阅读代码,可能会弄清楚为什么图像没有最终出现在我的服务器上,因为我似乎对此感到大脑冻结: (

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

?>

任何帮助都会很棒:)

【问题讨论】:

  • 我没有收到任何错误消息,只是上传的跟踪消息。但是当我检查服务器时没有图片! :(
  • 好的,所以我从 php 中移动了 if 语句,它创建了文件夹,但图片不在文件中:(
  • 好吧,代码一直都在工作,这看起来多么令人尴尬,这一定是我正在使用的一张狡猾的 .jpeg 图片,因为它只是与另一张图片一起工作:)

标签: php actionscript-3 file-upload flash-builder


【解决方案1】:

好吧,代码一直在工作,这看起来多么令人尴尬,这一定是一张狡猾的 .jpeg 图片

【讨论】:

    猜你喜欢
    • 2015-07-13
    • 2012-09-17
    • 1970-01-01
    • 2011-02-02
    • 2015-03-29
    • 2011-10-15
    • 1970-01-01
    相关资源
    最近更新 更多