Send a form value

44 views
Skip to first unread message

Roberto de Nobrega

unread,
Mar 5, 2012, 11:02:57 PM3/5/12
to SWFUpload
Hi,

I would like to send a form value to use it as the name of the
directory/pictures.

I have the form value $codigo. I need to send this value so SWFUpload
could use it to rename pictures names and create directory.

In practice:

User send a form with data, one of those is the $codigo (is a ramdom
number, no repeats).
After the form is sumitted, user upload the pictures. As I did a POST,
i can retrieve the $codigo using $codigo = $_REQUEST¨[codigo].

I need to send that $code value in the SFWupload proccess. So I can
use it to rename pictures and create directory:

if (!isset($_FILES['Filedata']) || !
is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
$error = 'Error al cargar las fotos';
}
else {

$codigo = $_REQUEST [codigo]

mkdir("../../imagenes/".$codigo , 0777);

move_uploaded_file($_FILES['Filedata']['tmp_name'], "../../
imagenes/".$codigo."/".$_FILES['Filedata']['name']);
chmod("../../imagenes/".$codigo."/".$_FILES['Filedata']['name'],
0777);

How can I send this $codigo value to SWFUpload..??? I am a newbie in
this, so try to be specific and use examples.!! xD

Thanks.! xD

Chris Rapier

unread,
Mar 6, 2012, 10:40:54 AM3/6/12
to swfu...@googlegroups.com
Roberto,

You should be able to do with this with the post_params setting. This,
of course, assumes that you are using $codigo in php and not trying to
pass it to javascript.

post_params: {"codigo": "$codigo"};

Alternatively you should also be able to make use of the $_SESSION
variable. Where ever you create $codigo you'd have
session_start();
$_SESSION['codigo'] = $codigo

and then in the upload target file (as specified by upload_url)
session_start();
$codigo = $_SESSION['codigo']

If you go the session route you may need to pass the PHPSESSID

so on the swfupload page you need to set
upload_url: "../upload.php", // Relative to the SWF file
post_params: {"PHPSESSID": "$my_session_id"},

and in upload.php

// Get the session Id passed from SWFUpload. We have to do this to
work-around the Flash Player Cookie Bug
if (isset ( $_POST ["PHPSESSID"] )) {
session_id ( $_POST ["PHPSESSID"] );
}

session_start ();
$codigo = $_SESSION['codigo']


Hopefully that helps
Chris

Roberto de Nobrega

unread,
Mar 6, 2012, 10:17:09 PM3/6/12
to SWFUpload
Thanks.!! The Session solution worked.!! xD

Chris Rapier

unread,
Mar 7, 2012, 12:48:13 PM3/7/12
to swfu...@googlegroups.com
Fantastic! Glad I could help out. Have fun!
Reply all
Reply to author
Forward
0 new messages