Jump to content
Sign in to follow this  
Ustag

php upload multiple files

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

Share this post


Link to post
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);

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...