|
||||||
| PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hello yall
I'm sure this must be a basic question but I'm still getting familiar with all this PHP stuff. Basically, what I am looking to do is to put together an image file-upload system which has a limit on the height and width that the user can upload. I have followed along with all the info contained at the W3schools site: PHP File Upload I understand that I will have to create my own function for this, but I don't quite know how to go about doing it. I found some sites that seem to have a solution, but they don't seem to be geared to my level of beginner. For instance - I found a site that seemed to describe how to do this (PHP Upload Images), but I do not understand these lines: Code:
$my_uploader->max_image_size(150, 150); // max_image_size($width, $height) Code:
/**
* void max_image_size ( int width, int height );
*
* Sets the maximum pixel dimensions. Will only be checked if the
* uploaded file is an image
*
* @param width (int) maximum pixel width of image uploads
* @param height (int) maximum pixel height of image uploads
*
*/
function max_image_size($width, $height){
$this->max_image_width = (int) $width;
$this->max_image_height = (int) $height;
}
Conceptually, I understand what needs to be done: compare the width and height of the uploaded image to pre-defined variables, but I do not know how to execute this. Any help is appreciated. |
| Sponsored Links |
|
|
|
|||||
|
The code you posted above is object oriented, and most beginners dont understand the syntax as they are use to procedural programming. Essentially the lines you posted above don't do anything but set the maximum width and height allowed, it doesn't actually check if the image that is intended to be uploaded is within the constraints you set.
Use getimagesize() on your temporary file. For an example, check out my PHP: Upload Class. This class is object oriented so I'm sure you won't understand most of it, however this is what is really of your concern. PHP Code:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall Last edited by John; 10-16-2007 at 09:19 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| File Manager | Jaan | Community Projects | 45 | 08-27-2008 12:11 PM |
| Windows XP Tricks & Tips!!!!..new ones. | pranky | Tutorials | 9 | 08-23-2008 04:22 PM |
| Upload a file | jacobronniegeorge | Visual Basic Programming | 1 | 09-11-2007 09:40 AM |
| How to add upload file | Kleopatra | HTML Programming | 3 | 07-23-2007 09:42 PM |
| text file manipulations in vb6.0 | Ronin_paes | Visual Basic Programming | 3 | 06-11-2007 05:54 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 97%