calmchess Posted December 15, 2009 Share Posted December 15, 2009 here is a script i am using for my uploads after button press it executes the problem is I have to browse and press the button twice before it works? What is wrong ? $arr0 = array(); if (isset($_POST['uploaded1'])){ echo "this0"; if(!$_FILES['mailfile']['size']||$_FILES['mailfile']['size']>0&&$_FILES['mailfile']['size']<4000||$_FILES['mailfile']['size']>5242880||$_FILES['mailfile']['type']!="image/gif"&&$_FILES['mailfile']['type']!="image/pjpeg"&&$_FILES['mailfile']['type']!="image/x-png"&&$_FILES['mailfile']['type']!="image/png"&&$_FILES['mailfile']['type']!="image/jpeg"&&$_FILES['mailfile']['type']!="image/bmp"&&$_FILES['mailfile']['type']!=null){ if($_FILES['mailfile']['size']>0&&$_FILES['mailfile']['size']<4000||$_FILES['mailfile']['size']>5242880){$arr0[0]='<small class="req0">between 4KB-5MB</small>';}else{$arr0[0]='<small>between 4KB-5MB</small>';} if($_FILES['mailfile']['type']!="image/gif"&&$_FILES['mailfile']['type']!="image/pjpeg"&&$_FILES['mailfile']['type']!="image/x-png"&&$_FILES['mailfile']['type']!="image/png"&&$_FILES['mailfile']['type']!="image/jpeg"&&$_FILES['mailfile']['type']!="image/bmp"&&$_FILES['mailfile']['type']!=null){$arr0[1]='<small class="req0">only .jpg .gif .png .bmp allowed</small>';}else{$arr0[1]=null;} $_SESSION['err1']=$arr0; $_SESSION['setses21']=true; header('Location: http://privatechatnow.com/currentwebsite/activation/upage.php?id='.$id."&doc=".$doc); return; } $getn = getuname($id); $type = $_FILES['mailfile']['type']; echo $type; if(stripos($type,'pjpeg')!==False){ $type1 =".jpg"; } if(stripos($type,'gif')!==False){ $type1 =".gif"; } if(stripos($type,'png')!==False){ $type1 =".png"; } if(stripos($type,'bmp')!==False){ $type1 =".bmp"; } $newname = uniqid("leg").$type1; if(move_uploaded_file($_FILES['mailfile']['tmp_name'], "../legalstorage/$getn/$newname")){ $_SESSION['setform']=true; $_SESSION['pic']= 0; header("Location: http://privatechatnow.com/currentwebsite/activation/upage.php?id=$id&doc=$doc"); }else{ $_SESSION['setform']=true; $_SESSION['pic']= 1; header("Location: http://privatechatnow.com/currentwebsite/activation/upage.php?id=$id&doc=$doc"); } } Quote Link to comment https://forums.phpfreaks.com/topic/185235-help-with-upload-script/ Share on other sites More sharing options...
calmchess Posted December 15, 2009 Author Share Posted December 15, 2009 ok i found the problem but there seems to be no explnation the first time i press the buttons the sessions aren't being registered but the second time i press the button they get registered ......same code same routine both times just takes executing things twice to get it to register the session variables ...what could be causeing the trouble? Quote Link to comment https://forums.phpfreaks.com/topic/185235-help-with-upload-script/#findComment-977855 Share on other sites More sharing options...
steveboj Posted December 15, 2009 Share Posted December 15, 2009 There doesn't appear to be a "session_start();" at the top of your script? Quote Link to comment https://forums.phpfreaks.com/topic/185235-help-with-upload-script/#findComment-977863 Share on other sites More sharing options...
PFMaBiSmAd Posted December 15, 2009 Share Posted December 15, 2009 The host name part of the URL is probably www. when you first visit the page, but your redirect just goes to yourdomain.com (without the www.) and the session.cookie_domain setting is not set to match both versions of yourdomain. You either need to set session.cookie_domain (before every session_start) to .yourdomain.com (with the leading dot as part of the setting) or you need to set up your web server so that it always redirects requests to the www. version of yourdomain. Quote Link to comment https://forums.phpfreaks.com/topic/185235-help-with-upload-script/#findComment-977864 Share on other sites More sharing options...
calmchess Posted December 15, 2009 Author Share Posted December 15, 2009 yeah that was the problem just figured it out myself.....this is the second time in 2 weeks that i've had that problem geesh......thanks for your time. Quote Link to comment https://forums.phpfreaks.com/topic/185235-help-with-upload-script/#findComment-977866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.