/    Sign up×
Community /Pin to ProfileBookmark

Quick help: image size check

hey all

I’m using the [URL=”http://www.pixeline.be/experiments/jqUploader/setup.php”]jqUploader[/URL] to upload an image.

However I’d like to restrict the uploaded images to a size of 500px x 300px (width x height)

I know it involves the use of getimagesize() but I’m a very amateur phpr and have no idea where or how to insert it into the following code…

[code=php]<?php

$uploadDir = dirname(__FILE__) . ‘/images/hq/’;
$uploadFile = $uploadDir . basename($_FILES[‘Filedata’][‘name’]);

if ($_POST[‘submit’] != ”) {
// 1. submitting the html form
if (!isset($_GET[‘jqUploader’])) {
// 1.a javascript off, we need to upload the file
if (move_uploaded_file ($_FILES[0][‘tmp_name’], $uploadFile)) {
// delete the file
// @unlink ($uploadFile);
$html_body = ‘<h1>File successfully uploaded!</h1>’;
} else {
$html_body = ‘<h1>File upload error!</h1>’;

switch ($_FILES[0][‘error’]) {
case 1:
$html_body .= ‘The file is bigger than this PHP installation allows’;
break;
case 2:
$html_body .= ‘The file is bigger than this form allows’;
break;
case 3:
$html_body .= ‘Only part of the file was uploaded’;
break;
case 4:
$html_body .= ‘No file was uploaded’;
break;
default:
$html_body .= ‘unknown errror’;
}
$html_body .= ‘File data received.’;
}
$html_body = ‘Image uploaded. Check your HQ page.<br>You will need to go to a different calendar and back again to see a change.’;

} else {
// 1.b javascript on, so the file has been uploaded and its filename is in the POST array
$html_body = ‘Error’;
}
myHtml($html_body);
} else {
if ($_GET[‘jqUploader’] == 1) {
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 2. performing jqUploader flash upload
if ($_FILES[‘Filedata’][‘name’]) {
if (move_uploaded_file ($_FILES[‘Filedata’][‘tmp_name’], $uploadFile)) {
// delete the file
// @unlink ($uploadFile);
return $uploadFile;
}
} else {
if ($_FILES[‘Filedata’][‘error’]) {
return $_FILES[‘Filedata’][‘error’];
}
}
}
}
// /////////////////// HELPER FUNCTIONS
function myHtml($bodyHtml)
{

echo $bodyHtml;

}

?>[/code]

thanks in advance

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@iotaFeb 26.2008 — http://www.php.net/getimagesize



-----------------------------------------
http://yehg.org
×

Success!

Help @treelovinhippie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...