andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Cant Get Upload to Work!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
oceanrockn
Newbie


Joined: 29 Nov 2004
Posts: 2
Location: Fort Lauderdale, Florida, USA

PostPosted: Mon Nov 29, 2004 9:32 pm    Post subject: Cant Get Upload to Work! Reply with quote

I am currently using another script to crop images, but I like yours a lot more, it?s the best I have seen. The images a clearer and sharper using your program.

I know PHP pretty well, but feeling stupid today. I have worked on this script for hours and hours and can not get my upload to work, it works if I use a file already loaded to the server.

I also would like to upload different size images and crop to the same size thumbnail (135 x 135).

If some could help I would really appreciate it.

Thanks
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Nov 30, 2004 5:50 am    Post subject: Re: Cant Get Upload to Work! Reply with quote

Hi and welcome to the board!

oceanrockn wrote:
I am currently using another script to crop images, but I like yours a lot more, it’s the best I have seen. The images a clearer and sharper using your program.


I'm glad you like it. Smile

oceanrockn wrote:
I know PHP pretty well, but feeling stupid today. I have worked on this script for hours and hours and can not get my upload to work, it works if I use a file already loaded to the server.


Here's a pretty simple upload script:

PHP:
<?php

    define
('BASE_DIR',  $_SERVER['DOCUMENT_ROOT'] . '/');
    
define('IMAGE_DIR'BASE_DIR 'images');

    if (!isset(
$_FILES) || empty($_FILES)) {
        echo 
'<form action="" method="post" enctype="multipart/form-data">';
        echo 
'Select your image type to upload<br />';
        echo 
'<input type="file" name="image"> <input type="submit" value="upload"><br />';
        echo 
'</form>';
    } else {
        
$filename str_replace(' ''_'preg_replace('/\s+/'' 'preg_replace('/[^a-z0-9-_ ]/i'''$_FILES['image']['name'])));
        if (
move_uploaded_file($_FILES['image']['tmp_name'], IMAGE_DIR $filename)) { 
            
// do you processing on the file here
            // IMAGE_DIR . $filename
        
} else {
            echo 
'There was an error uploading that file.';
            
print_r($_FILES);
        }
    }

?>


If that doesn't work (assuming I've made no typos in the syntax, of course!), then check the permissions of the directory you're trying to upload to just incase PHP doesn't have write permissions.

oceanrockn wrote:
I also would like to upload different size images and crop to the same size thumbnail (135 x 135).


Easy! How you implement it, though, is up to you. For example, you may want to resize the image first to a thumbnail size of a minimum dimension of 135 pixels, and then just centre crop the image to get 135x135. Or you may want to just crop a portion of the image, no matter what size it is, to 135x135. Both of those can work automatically without any user intervention. However, you could also use the cropping interface so that when you have uploaded an image you ask someone to crop it. You could also automatically resize before showing the cropping interface... It really all depends on what you want to do. But I would recommend that if you want to resize that you also check out the 'drop shadow' class. Don't be fooled by the name - it's a powerful thumbnailer!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group