all groups > flash actionscript > june 2006 >
You're in the

flash actionscript

group:

FileReference doesn't work with PHP Globals


FileReference doesn't work with PHP Globals Webmaster Pete
6/13/2006 9:46:34 PM
flash actionscript: <help>,

Ok so this is my problem. I have a flash movie that allows users to uploads
two images to a server. What I'm trying to do is have the uploaded images go
directly to their user's directory. I need the upload.php file to figure out
which person is uploading an image. The php page that handles the file uploads
will not read in any global variables (i.e. POST, GET, SESSION, COOKIE). Also
FileReference.upload() doesn't allow you to send any GET / POST vars along
with it (as far as I have tested and read about). I've been working on this for
four days now and have concluded it's something to do with the Flash
FileReference calling the php page. I believe for some reason when
FileReference calls the php page the web server doesn't like/allow/understand
how the page is called so it denies any global var requests. I know its flash
because it works if I use an html front end with the same php uploader page.

So the goal for you 'out of the box' thinkers is to get one single darn
global variable pulled into the php upload page. The ONLY way I can think of
doing this is when every time a user creates an account and their folder is
created, it copies the php upload file their directory. Then in flash when a
user needs to upload its calls the upload file in each persons upload
directory. Needless to say I do not want to do it this way but I'm running out
of ideas.

P.S. someone has suggested uploading the images to a temp file name and then
immediatly move the image to the users folder but I I'm tentive to do it that
way since you could get two people uploading at the same time and one person
would get the second person's image and the second person would get an error.

<!--- actionscript code
this._fileRef.upload("upload.php"); <---- works
this._fileRef.upload("upload.php?user_id=4"); <---- does not work
//-->

<?php
session_start();
$user_id = $_SESSION['user_id']; // Does not work
$user_id = $_COOKIE['user_id']; // Does not work
$user_id = $_GET['user_id']; // Does not work
$user_id = $_POST['user_id']; // Can't do with FileReference class
?>

</help>
Re: FileReference doesn't work with PHP Globals Motion Maker
6/14/2006 11:18:36 AM
This may help. You can pass some URL encoded data with the FileReference
upload method.

file_fr.upload("upload.php?testvar=Hello World " +Date());

Then this is a demo on how you can see that data, which you would need to
rework to use to set the path.
<?php
if ($_FILES['Filedata']['name']) {
$uploadDir = "images/";
$uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);
move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile);
}
$filename = "output.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "Test" );
fwrite ( $fp, $_REQUEST['testvar'] );
fclose( $fp );

?>

--
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
[quoted text, click to view]

Re: FileReference doesn't work with PHP Globals nilu_only
6/19/2006 12:00:00 AM
try this i think it works

$user_id = $_REQUEST['user_id'];

AddThis Social Bookmark Button