Jump to content

help with upload script


calmchess

Recommended Posts

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");

}

}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.