Reputation: 109
i have a form with one file input and a submit button, The action attribute of the form set to 'upload.php' where i have my php script to rename the file and save it to a specific folder, But also i need some javascript variables for resizing and cropping the uploaded image. What is the best way to send them both at the same time to be used by php script.
Thanks you very much..
this is javascript code:
$('.upload_form').submit(function(){
var crop_position_top = $('.crop_div').position().top;
var crop_position_left = $('.crop_div').position().left;
var img_position_top = $('.upload_preview').position().top;
var img_position_left = $('.upload_preview').position().left;
var crop_start_x = img_position_left - crop_position_left;
var crop_start_y = img_position_top - crop_position_top;
var crop_tool_width = $('.crop_div').width();
var crop_tool_height = $('.crop_div').height();
var img_name = $('.upload_img_input').val();
$.post("upload.php", {start_x: crop_start_x, start_y: crop_start_y, crop_width: crop_tool_width, crop_height:crop_tool_height});
});
Upvotes: 1
Views: 59
Reputation: 66
You can add hidden input such as
And you can dynamically allocate value using javascript based on your action
Upvotes: 1