2011-12-08 23 views
0

このコードを作成しようとしていましたが、私のコードよりも優れたコードを読んでいる人がなぜイメージが終わるのか私のサーバー上で私は、これは、サーバー上のPHPをAS3と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 
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

okだから私はPHPからifステートメントを移動して、フォルダを作成したが、そのファイルはファイル内にはない:( – WhiteFinger

+0

OKコードは常に厄介なものになっていた。私はそれがちょうど別のものと働いたとして使用していたjpeg画像:) – WhiteFinger

答えて

1

[OK]を十分だろうどのような勇気コードはいつもうまくいっているようだ.jpg画像の

関連する問題