28, May 2012

Directory Creation Problem in Foto_upload class - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Directory Creation Problem in Foto_upload class
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Directory Creation Problem in Foto_upload class  (Read 1614 times)
Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« on: May 09, 2006, 01: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: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: May 09, 2006, 01: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(falsefalsetrue80);
$foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"// "file_copy is the name of the foto"
}
}

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #2 on: May 09, 2006, 01:39:13 pm »

Hi Olaf,
We are leagues apart.
mark
clue: why do define a constant and not use it?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: May 09, 2006, 01:44:34 pm »

Hi Olaf,
We are leagues apart.
mark
clue: why do define a constant and not use it?
which one? I create constants to have global access

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: May 09, 2006, 01:46:44 pm »

just noticed that the definition of the thumbnail folder is not important if the settings inside the process_image() method are right:

Code:
<?php
function process_image($landscape_only false$create_thumb false$delete_tmp_file false$compression 85) {

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2460
Tags : php Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Directory Creation Problem in Foto_upload class
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 10:59:16 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.