Hi, I have a file upload function, but it's only permitted to upload max 2 mb.
First of all, is it possible to change that anywhere?
And second of all, i'm having some trouble validating it so it will come with an error if the file exceeds 2 MB.
Hope someone can help, so far it's only validating if a file is beeing uploaded, but not sure how to validate the size.
This is my javascript code thanks:
Code:
<script language="javascript" type="text/javascript">
function validateForm()
{
var x=document.forms["profile"]["file_name"].value;
if (x==null || x=="")
{
alert("An image must be uploadet");
return false;
}
}
</script>
Oh ok sorry, I thought it would be in the same file, because the validation if there is a file being uploaded is in the javascript code that I posted.
but here is my php page:
PHP Code:
<?php
include_once( 'class/class.upload.php' );
if(isset($_POST['upload'])){
$filname=$_FILES['file_name'];
$handle = new upload($filname);
$handle->allowed = array('image/*');
if($handle->uploaded){
$handle->image_border = 5; // defining border width
$handle->image_border_color = '#000'; // defining border color
$handle->image_watermark = 'badge.png'; // watermark image src
$handle->image_watermark_position = 'BR'; // watermark image position again "B" for bottom and so on.
$handle->image_resize = true; // making resize function to true
$handle->image_x = 160; // making width to 160px
$handle->image_y = 160; // making hight to 160px
$handle->process('uploads/');
if ($handle->processed) {
Hmm ok, now I downloaded phuploader.php, and I've included it.
And I've tried to work abit with it, but I can imagine getting a problem when I submit the form.
Because in the program i've made before, I didn't keep the file saved in the folder and it would send the image uploaded as an attachment after it has made some changes to to image.
But in phuploader.php, there is already an upload button that uploads the images to the upload folder.
But how do I get the upload field to respond to my button and also send the file and do all the changes to the uploaded image.
hmm i'm kind of lost with this one.
Because the program that I have made, will let a user upload a picture and create a watermark on it and then send it to an email that the user writes.
First it validates with javascript if there has even been a file uploaded otherwise a popup with come where it says that there was no file.
Isn't there also a command so I can get the popup to write if the file exceeds 2mb?
My Javascript that already works if there is no file in the field looks like this:
Code:
function validateForm()
{
var x=document.forms["profile"]["file_name"].value;
if (x==null || x=="")
{
alert("An image must be uploadet");
return false;
}
}
Is there also a way to check if the file exceeds the size as simple as this, so it will come in a javascript popup, like it does if there is no file?
Bookmarks