Problem with my SESSION

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • htdIO
    New Member
    • May 2010
    • 4

    Problem with my SESSION

    Hey guys, i've been working on this for a few hours, so I think it is time I need som fresh eyes. I'm trying to store some variables with by using SESSION. I know it is being stored and that I can retrieve their values from other pages, but I can't from the one. Can somebody maybe just have a quick look at my code snippet and tell me if I'm missing something?

    Code:
    session_start();
    $cat = $_SESSION['cat'];
    $subcat = $_SESSION['subcat'];
    
    $filename	= $_FILES['Filedata']['name'];
    	$temp_name	= $_FILES['Filedata']['tmp_name'];
    	$error		= $_FILES['Filedata']['error'];
    	$size		= $_FILES['Filedata']['size'];
    	$randomName = genRandomString();
    	$ext = explode(".", $filename);
    	
    	/* NOTE: Some server setups might need you to use an absolute path to your "dropbox" folder
    	(as opposed to the relative one I've used below).  Check your server configuration to get
    	the absolute path to your web directory*/
    	if(!$error) {
    		copy($temp_name, '../dropbox/'."blah".$randomName.".".$ext[count($ext)-1].$subcat);
    	}
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    What happens if you var_dump the session variables? Does it show the correct data?

    And why are you attaching the $subcat value onto the file extension of the new file?

    P.S.
    You shouldn't use copy() to move uploaded files. You should use move_uploaded_f ile. Safer that way.

    Comment

    • htdIO
      New Member
      • May 2010
      • 4

      #3
      Originally posted by Atli
      What happens if you var_dump the session variables? Does it show the correct data?

      And why are you attaching the $subcat value onto the file extension of the new file?

      P.S.
      You shouldn't use copy() to move uploaded files. You should use move_uploaded_f ile. Safer that way.
      Thanks for the reply. When I var_dump I get nothing.

      Thats my bad, I forgot I put it there. It was just another way of testing if the variable has been set.

      Lastly, thanks for the advice, will do that. I have decided to rewrite my whole script now. I missed a few important things that will be too hard to add in now.

      Comment

      Working...