Jump to content

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


GremlinP1R

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

  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.

×
×
  • Create New...

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.