php - Hi. My Uploadify script don't see are $_SESSION -


    function usersingin( )     {              $login = common::getglobals('userlogin');         $pass  = common::getglobals('userpassword');          $reg = false;          $users = $this->db->get("select userid, userlogin, userpassword users");          foreach( $users $_users )         {             if( $_users->userlogin == $login && $_users->userpassword == md5( $pass ) )             {                 //$sess->set('userhash', md5( $login.$pass.$salt ) );                 session::set('uid', $_users->userid );  // set userid                 $reg = true;             }         }          echo $reg ? "ok" : "error";     }  =================================================      $(function()      {          $('#file_upload').uploadify(         {             'filesizelimit'    : '1000kb',             'queuesizelimit'   : 1,             'filetypedesc'     : 'image files',             'filetypeexts'     : '*.gif; *.jpg; *.png',             'removetimeout'    : 3,             'swf'              : '/application/userdata/js/uploadify/uploadify.swf',             'uploader'         : '/ajax/uploadavatar/',              'onuploaderror' : function(file, errorcode, errormsg, errorstring) {             alert('the file ' + file.name + ' not uploaded: ' + errorstring);             },              'debug' : true           });     });  =================================================      public function uploadavatar()     {          //include_once("application/tools/resize.php");          $targetfolder = '/application/userdata/upload/avatars/';           if ( !empty ( $_files ) )          {             $tempfile = $_files['filedata']['tmp_name'];             $fname    = $_files['filedata']['name'];              $exp      = explode( '.', $fname );             $ext      = end( $exp );              $newname  = md5( $_files['filedata']['name']. rand( 1, php_int_max ) );              $targetpath = $_server['document_root'] . $targetfolder;             $targetfile = rtrim($targetpath,'/') . '/' . $newname.'.'.$ext;              $filetypes = array('jpg','jpeg','gif','png');             $fileparts = pathinfo($_files['filedata']['name']);               if (in_array($fileparts['extension'],$filetypes)) {             move_uploaded_file($tempfile,$targetfile);             echo 'file uploaded';             } else {             echo 'invalid file type.';             }         }          print_r( $_session ); // empty...     }  =================================================

in file when use print_r( $_session ) it's right.

this problem i've seen while doing flex, upload through flash seems not use cookies (and loses sessions). if uploadify uses flash problem.

you might fix setting token identifying user , instead of uploading http://example.com/upload.php ought upload http://example.com/upload.php?token=azpodkazpoj1dzapdo (you upload script has implement mechanism find , check user token.

edit : suggested in suspected duplicate question, can use session_id token


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - EclipseLink JPA Object is not a known entity type -

java - Need to add SOAP security token -