close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Validating image size before uploading

Thread began 3/05/2018 9:46 am by iain331081 | Last modified 3/14/2018 3:49 pm by anonymous | 2567 views | 15 replies |

iain331081

Validating image size before uploading

This is one I had some help about ages ago, and had a page checking the the width of an image fell between two values. I now have a requirement to check the image is an exact size, so need it to check the height and the width.

I have attached a page with what I thought it should be, but doesn't seem to be.

Can you have a quick look and let me know what I have wrong? I think it must be something along these lines.

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

You need to move the file upload code above the validation code in order to validate the dimensions. Then you would also have to use the bindings from the file upload for the width and the height and not the values from the $_FILES array.

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray,

Sign in to reply to this post

Ray BorduinWebAssist

It should be something like:
$WAFV_Errors .= WAValidateNM($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["imageWidth"] . "",299,301,"",",.",true,1);
$WAFV_Errors .= WAValidateNM($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["imageHeight"] . "",199,201,"",",.",true,3);

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray - I think you might have used a slightly different method when I asked about this originally.

Sign in to reply to this post

Ray BorduinWebAssist

Yes. If you add code like that above it will allow you to validate the size without moving the upload code above. This is actually a better technique since you wouldn't have already uploaded the file before validation and wouldn't need to clean up old files that didn't meet the validation requirement.

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Can you see where I've gone wrong with the validation on the height? Its failing the validation even with a 300x200 image.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the latest version of the file you are working on. I'll take a look.

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray.

Sign in to reply to this post

Ray BorduinWebAssist

You have:
$image_info = getimagesize($_FILES["news_image_small"]["tmp_name"]);
$_FILES["news_image_small"]["height"] = $image_info3[0];

it should be:
$image_info3 = getimagesize($_FILES["news_image_small"]["tmp_name"]);
$_FILES["news_image_small"]["height"] = $image_info3[0];

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...