close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Compress Image Size on Upload

Thread began 8/13/2020 6:47 am by LWat85283715 | Last modified 8/27/2020 2:02 pm by Ray Borduin | 15 views | 4 replies |

LWat85283715

Compress Image Size on Upload

I have a form that uploads an image no problem when it is under 10MB. But, if it is over 10MB, it fails. Is there a way to compress any image a person try to uploads to 10MB or less? Here is my code:

// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "admin/received",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "400",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End

WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["submit"]) || isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "id_image", "2", "", "false", $WA_UploadResult1_Params);

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

You can't compress before uploading. You are already compressing after upload. You just have to increase your memory limit most likely.

Try adding this to the top of your page:

php:
<?php

ini_set
('memory_limit','256M');
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

LWat85283715

Hmm. That still didn't help. So, if they are uploading an image and we need the image size to be smaller, what should this be set to:
'ResizeType' => "0",

If they are uploading a pdf, what should it be set to?

If the upload fails, is there a message I can display and have it prevent the form from submitting? For some reason, when I use the WebAssist links in Adobe Dreamweaver 2020, they don't work so I have been handcoding it from old code. So, I can't use the validation links.

Sign in to reply to this post

LWat85283715

I added this to the page:

if($WA_DFP_UploadStatus["WA_UploadResult1"]["statusCode"] == 20 or $WA_DFP_UploadStatus["WA_UploadResult1"]["statusCode"] == 30 or $WA_DFP_UploadStatus["WA_UploadResult1"]["statusCode"] == 0){
echo "The file you are trying to upload is too large. Please compress the file before uploading.";
}

Would this work?

Sign in to reply to this post

Ray BorduinWebAssist

I'd have to do some testing, but that might work as long as the code was in the correct location. You can't really compress and resize .pdf files since they are already pretty well compressed, so an error like this would make sense as a solution.

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

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...