Jump to content


Photo

File upload... Need help with extention and to loop....


  • Please log in to reply
1 reply to this topic

#1 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 18 October 2006 - 08:08 PM

Can some one please HELP ME.......

Okay got it to work but the extention is a problem.... for some reason it does not pick it up....
This is what I have...

<?php
// Validation of File Extension
   function validate_extension() {
   
   // Section #1 - Defining variabels
      $file_name = trim($this -> file_name);
	  $extension = strtolower(strrchr($file_name, "."));
	  $ext_array = $this -> ext_array;
	  $ext_count = count($ext_array);
	  
   // Section #2 - Validate File Name and Extension
      if (!$file_name) {
	      return false; }
	  else { 
	     if (!$ext_array){
		     return true;}
		 else {
		    foreach ($ext_array as $value) {
			         $first_char = substr($value, 0, 1);
				     if ($first_char <> ".") {
					     $extensions[] = "." .strtolower($value); }
				     else {
					       $extensions[] = strtolower($value); }
						  }
						  
   // Section #3 - Loop using right extension - Check for acceptance
      foreach ($extensions as $value) {
	     if ($value == $extension) {
		     $valid_extension = "TRUE" ;
	     }
	   }
	   
   // Section #4 - 
      if ($valid_extension) {
	     return true; }
	    else {
	       return false;}
	         }	  
	      }
	  }
?>

it keeps on telling me that the extention is undefined.... and the how do I make this loop??

<?php
// When Submitting
   if (isset($_POST['Submit'])) {
   include('uploadclass.php');
		  
   // Set upload info
      $upload_class = new Upload_Files;
	  $upload_class -> temp_file_name = trim($_FILES['pic1']['tmp_name']);
	  $upload_class -> file_name = trim(strtolower($_FILES['pic1']['name']));
	  $upload_class -> upload_dir = "images/cars/";
	  $upload_class -> upload_log_dir = "images/uploadlog/";
	  $upload_class -> max_file_size = 500000000;
	  $upload_class -> banned_array = array(" ");
	  $upload_class -> ext_array = array(" .jpg");
	  
   // Calling class Functions
//      $valid_ext = $upload_class -> validate_extension();
	  $valid_size = $upload_class -> validate_size();
	  $valid_user = $upload_class -> validate_user();
	  $max_size = $upload_class -> get_max_size();
	  $file_size = $upload_class -> get_file_size();
	  $upload_directory = $upload_class -> get_upload_directory();
	  $upload_log_directory = $upload_class -> get_upload_log_directory();
	  $upload_file = $upload_class -> upload_file_no_validation();
?>

as I have 4 pics to upload at the same time....

Thanx

#2 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 18 October 2006 - 09:25 PM

Any one please




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users