Jump to content

Flash/php picture folder creation problem when on HTML/swf


nightkarnation

Recommended Posts

Hello!

 

I have this application in flash (works along with php and mysql) that has a function that lets the user upload his picture...

 

When i try it on (localhost) flash and or opening the swf...it works great...but when i try out on explorer (html) the status says picture succesfully uploaded...but on the folder im saving them, its just not there...

Im guessing there's something missing on the php code, please take a look:

 

//IRRELEVANT CODE (please read more below):
        $connect = mysql_connect("localhost", "bleh", "*****"); 
        mysql_select_db("learning", $connect); 
	$query  = "SELECT user_id FROM `acc_data` 
ORDER BY `acc_data`.`last_connection` DESC LIMIT 0 , 30";
$result = mysql_query($query);
$cant = 0; 
while(list($user_id)= mysql_fetch_row($result))
{
//aca esta haciendo un loop sacando todos los user_id ordenados por tiempo
	 $cant++;
	 //Aca lo obliga si o si a agarrar al 1ro de la tabla
	 if ($cant == 1) {
	 $userName=$user_id . "_0";
	 echo "Name :$user_id <br>" .
         "Count : $count <br><br>";
	 }

}
//---------------RELEVANT CODE:

$target = "images/";
list($filename, $extension) = explode('.', basename($_FILES['Filedata']['name']));
//$filename = sha1($filename);
$filename = $userName;
$target = $target . $filename . "." . $extension;

$name=$_POST['name'];
$pic=($_FILES['photo']['name']); 

//create the directory if doesn't exists (should have write permissons)
if(!is_dir("./images")) mkdir("./images", 0755);
//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], $target);
//chmod("./files/".$_FILES['Filedata']['name'], 0777); <---- i've tried with this code enabled also

Here's the flash code...maybe it helps:

 

//PICTURE UPLOAD SECTION:--------------------------------------------------------
//Allow this domain
//System.security.allowDomain("./images/", "127.0.0.1");
import flash.net.FileReference;
// The listener object listens for FileReference events.
var listener:Object = new Object();
// When the user selects a file, the onSelect() method is called, and
// passed a reference to the FileReference object.
listener.onSelect = function(selectedFile:FileReference):Void  {
//upload the file name information
content_lv.action = "uploadPicture";
content_lv.userName = myUserId;
content_lv.sendAndLoad("login.php", content_lv, "POST");
//clean statusArea and details area
txtStatus.text = "";
// Flash is attempting to upload the image.
txtStatus.text = "Attempting to upload "+selectedFile.name;
// Upload the file to the PHP script on the server.
// y tambien chequea hasta que recibe el ok desde login.php
_root.onEnterFrame = function() {
	trace("ENTRO AL FRAME!");
	if (content_lv.imdone == true) {
		selectedFile.upload("upload.php", content_lv, "POST");
		trace("UPLOADING ACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
		delete this.onEnterFrame;
	}
};
};
// the file is starting to upload.
listener.onOpen = function(selectedFile:FileReference):Void  {
txtStatus.text = "Uploading "+selectedFile.name;
};
listener.onComplete = function(selectedFile:FileReference):Void  {
txtStatus.text = "Success Uploading "+selectedFile.name;
};
//Possible file upload errors
listener.onHTTPError = function(file:FileReference, httpError:Number):Void  {
txtStatus.text = "error";
txtStatus.text = "HTTPError number: "+httpError+"\nFile: "+file.name;
};
listener.onIOError = function(file:FileReference):Void  {
txtStatus.text = "error";
txtStatus.text = "IOError: "+file.name;
};
listener.onSecurityError = function(file:FileReference, errorString:String):Void  {
txtStatus.text = "error";
txtStatus.text = "SecurityError: "+SecurityError+"\nFile: "+file.name;
};
var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);
btnUploadPicture.onPress = uploadImage;
imagePane.addEventListener("complete", imageDownloaded);
// Call the uploadImage() function, opens a file browser dialog.
function uploadImage(event:Object):Void {
imageFile.browse([{description:"Image Files", extension:"*.jpg;*.gif;*.png"}]);
content_lv.imdone = false;
}
//</PICTURE UPLOAD SECTION:--------------------------------------------------------------------------------------

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.