Jump to content

Archived

This topic is now archived and is closed to further replies.

GremlinP1R

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

Recommended Posts

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...

[code]<?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;}
        }  
      }
  }
?>[/code]

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

[code]<?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();
?>[/code]

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

Thanx

Share this post


Link to post
Share on other sites

×

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.