Topic: Directory Creation Problem in Foto_upload class (Read 748 times)
Atari ST fan
Posts: 8
52 credits Members referred : 0
« on: May 09, 2006, 02:13:29 PM »
Hi, I came across a small problem in the Foto_upload class where if you don't want a thumb nail created the method process_image would still try and create a thumbs directory [see line: $this->check_dir($this->thumb_folder);] even if the thumb_folder variable was not initialised. Which resulted in a PHP error. One way round it was to move the
$this->check_dir($this->thumb_folder);
into the if statement below if ($create_thumb) { $this->check_dir($this->thumb_folder);
Now the folder is only created if the a thumb nail has been flagged to be created. Not sure if anyone is interested in suggestions like this. mark
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6301
38632 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: May 09, 2006, 02:34:03 PM »
why?
check this modified example:
Code:
<?php $max_size = 1024*1024; // the max. size for uploading (~1MB) define("MAX_SIZE", $max_size); $foto_upload = new Foto_upload;
$foto_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/test_files/"; // "files" is the folder for the uploaded files (you have to create these folder) $foto_upload->foto_folder = $_SERVER['DOCUMENT_ROOT']."/test_files/photo/"; $foto_upload->thumb_folder = $_SERVER['DOCUMENT_ROOT']."/test_files/"; $foto_upload->extensions = array(".jpg"); // specify the allowed extension(s) here if (isset($_POST['Submit']) && $_POST['Submit'] == "Upload") { $foto_upload->the_temp_file = $_FILES['upload']['tmp_name']; $foto_upload->the_file = $_FILES['upload']['name']; $foto_upload->http_error = $_FILES['upload']['error']; $foto_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true $foto_upload->do_filename_check = "n"; if ($foto_upload->upload()) { $foto_upload->process_image(false, false, true, 80); $foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"; // "file_copy is the name of the foto" } }