30, August 2008

Directory Creation Problem in Foto_upload class - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

Author 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: Male
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(falsefalsetrue80);
$foto_upload->message[] = "Processed foto: ".$foto_upload->file_copy."!"// "file_copy is the name of the foto"
}
}


Last blog : Is your website is down? Know before your visitors do!
Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #2 on: May 09, 2006, 02: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: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: May 09, 2006, 02: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


Last blog : Is your website is down? Know before your visitors do!
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: May 09, 2006, 02: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) {


Last blog : Is your website is down? Know before your visitors do!
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2460
Tags : php Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Aug 30, 2008, 04:00:26 PM





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!


Forum Statistics
Total Posts: 36.192
Total Topics: 7.462
Total Members: 3.866
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: shopforindia

42 Guests, 4 Users online :

16 users online today:



Readers

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