File Upload script + Duplicate Checking + help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

File Upload script + Duplicate Checking + help

Post by harsha »

HI
ALL

I am writing a file upload script I am able to upload the file and add the file name to the list,
And it is now able to check the duplicates to some extent,
I have written the code for checking duplicates which works fine on certain conditions only.

Code: Select all

<?
if(isset($_POST['fileAttach']) AND isset($_POST['selFileList']))
  {
	if(is_array($_POST['selFileList']) AND (count($_POST['fileAttach']) > 0))
	  {
		$duplicate_file = array();
		foreach($_POST['selFileList'] as $uploadFileName)
		  {
			foreach(array_unique($_FILES['fUploader']['name']) as $file_name)
			  {
			    if(strcasecmp($uploadFileName, $file_name) == 0)
				  {
				     array_push($duplicate_file, $file_name);
				  }
			  }
		  }
	  }
  }
?>
<select name="selFileList[]" size="6" multiple class="FILE" id="selFileList"><?
if(isset($_POST['fileAttach']))
  { 
  	$upload_tmp_name = array_unique($_FILES['fUploader']['tmp_name']);
	foreach(array_unique($_FILES['fUploader']['name']) as $file_number => $file_name)
	 {
       $uploadedFileName = $file_name;
       $temporaryFileName = $upload_tmp_name[$file_number];
	   if(isset($duplicate_file) AND (count($duplicate_file) > 0))
		 {
			foreach($duplicate_file as $duplicate_name)
			  {
				if(!(strcasecmp($duplicate_name, $uploadedFileName) == 0))
				  {
					if(move_uploaded_file($temporaryFileName, $sg_usersFileUploadDir.$uploadedFileName))
					  {
						echo "<option value=\"{$uploadedFileName}\">".$uploadedFileName."</option>\n\n";      
					  }
				  }
			  }
		}
	   else 
		{
		   if(move_uploaded_file($temporaryFileName, $sg_usersFileUploadDir.$uploadedFileName))
			{
				echo "<option value=\"{$uploadedFileName}\">".$uploadedFileName."</option>\n\n";      
			}
		}
	 }//foreach;
	if(isset($_POST['selFileList']))
	 {
		foreach($_POST['selFileList'] as $file_key => $file_value)
		  {
			 echo "<option value=\"{$file_value}\">".$file_value."</option>\n\n";
		  }
	 }
  } //fileAttach;
else if(isset($_POST['toform2']) AND isset($_POST['selFileList']))
  {
	foreach($_POST['selFileList'] as $value) 
	  {
		echo "<option value=\"{$value}\">".$value."</option>\n\n";
	  }
  }      
else if(isset($_POST['btnRemove']) AND isset($_POST['selFileList']))
  {
	foreach($_POST['selFileList'] as $file_key => $file_value)
	  {
		echo "<option value=\"{$file_value}\">".$file_value."</option>\n\n";
	  }
  }
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

okay... and you want us to do or say what?
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Post by harsha »

No
Please help me by Highlight the mistake that i have done in the script,

:D thank you
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You didn't say what the problem was? :?
Post Reply