Jump to content

php upload multiple files


Ustag
 Share

Recommended Posts

hi I have problem with my file uploader which dont make sense for me. I am trying to upload 3 files with the following code but only one of them is being uploaded and its the .xbst file. Please have a look, it gives me no error message at all:

//image file	if (($_FILES['image']['error'] == 0) && ($_FILES["image"]["type"] == true))	{	 $ext = substr(strrchr($_FILES["image"]["name"], '.'), 1);  if (($ext == "jpg")  || ($ext == "JPG")  || ($ext == "jpeg")  || ($ext == "JPEG"))  {   if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755);   }   elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755);   }   elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key , 0755);   }   else   {	move_uploaded_file($_FILES["image"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key."/".$_FILES["image"]["name"]);   }  }  else  {   echo "Filetype not allowed: ".$_FILES["image"]["name"];		}} //xbst file	if (($_FILES['settings']['error'] == 0) && ($settings == true))	{  $ext = substr(strrchr($_FILES["settings"]["name"], '.'), 1);  if (($ext == "xbst")  || ($ext == "XBST"))  {   if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755);   }   elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755);   }   else   {	move_uploaded_file($_FILES["settings"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/".$_FILES["settings"]["name"]);   }  }  else  {   echo "Filetype not allowed: ".$_FILES["settings"]["name"];		}}//lua file	if (($_FILES['script']['error'] == 0) && ($script == true))	{  $ext = substr(strrchr($_FILES["script"]["name"], '.'), 1);  if (($ext == "lua")  || ($ext == "LUA"))  {   if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755);   }   elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755);   }   elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key)==false)   {	mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key , 0755);   }   else   {	move_uploaded_file($_FILES["script"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key."/".$_FILES["script"]["name"]);   }  }  else  {   echo "Filetype not allowed: ".$_FILES["script"]["name"];		}}

Thank you for your time!

Edited by Ustag
Link to comment
Share on other sites

You need to figure out where the others are failing. Add output so you can see which if statements it's going into, have it print out the values of variables that you're checking with the if statements, etc. And if you're not sure if all errors are being reported then add this to the top: ini_set('display_errors', 1);error_reporting(E_ALL);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...