Jump to content

Archived

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

GremlinP1R

Include() problem....

Recommended Posts

Hi there all.

I have done the file handeling tutorial of PHPFreaks but have a huge problem...
As soon as I include() that class file for the file uploading, my script goes blank it just dissapear...
And maybe if I can get that sorted I will be able to get the thing to work...

Please Help me.... Don't know where to start looking....

Thanx.

Share this post


Link to post
Share on other sites
Try to put [code]error_reporting(E_ALL);[/code] on the top of your page and see if it returns any errors.

Share this post


Link to post
Share on other sites
Help.... I used that code and it helped a lot thanx, quite a handy tool to have...

Sorted all errors out on the class script but now have a new problem.... I'm getting this....

[quote]Notice: Undefined index: upload in C:\wamp\www\P1R\memberspages\addmembers.php on line 339

Notice: Undefined index: upload in C:\wamp\www\P1R\memberspages\addmembers.php on line 340

[/quote]

Okay now I think that my problem are here some where and it just don't feel and look right it just look if I'm shorting something....

[code] 
// When Submitting
  if (isset($_POST['Submit'])){
      include('uploadclass.php');
  // Set upload info
      $upload_class = new Upload_Files;
      $upload_class -> temp_file_name = trim($_FILES['upload']['tmp_name']);      // line 339
      $upload_class -> file_name = trim(strtolower($_FILES['upload']['name']));    // line 340
      $upload_class -> upload_dir = "images/cars/";
      $upload_class -> upload_log_dir = "images/uploadlog/";
      $upload_class -> max_file_size = 5000000;
      $upload_class -> banned_array = array(" ");
      $upload_class -> ext_array = array(" .jpg", " .gif", " .jpeg", " .png", " .bmp");
 
  // Calling class Functions
      $valid_ext = $upload_class -> validate_extensions(); 
      $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_dir();
      $upload_log_directory = $upload_class -> get_upload_log_dir();
      $upload_file = $upload_class -> upload_file_with_validation();
 
  // Errors
      if (!$valid_ext){ $result = "file ext";}
  elseif (!$valid_size){ $result = "size";}
  elseif (!$valid_user){ $result = "user";}
  elseif ($file_exists){ $result = "exists";}
  else {$upload_file = $upload_class -> upload_file_with_validation();
      if(!$upload_file){ $result = "Not Uploaded";}
  else{ $result = "Success";}
      }
  }
[/code]

Please help.... Thanx

Share this post


Link to post
Share on other sites
$_FILES['upload'] is the part it's talking of.  An undefined index means the array index/key isn't defined anywhere.  $_FILES['upload'] should be the name of the field in your form ie:

<input type="file" name="upload"/>

If you use a different name there, they need to match either way.

HTH

Dest

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.