Author Topic: Upload Tool for 4Images written in Java  (Read 5751 times)

0 Members and 1 Guest are viewing this topic.

Offline JavaUploader

  • Pre-Newbie
  • Posts: 3
    • View Profile
Upload Tool for 4Images written in Java
« on: April 24, 2006, 10:23:41 PM »
Hi there,
i have written a small tool in java for my 4Image's Site. It gives every User the ability to upload images, by draging them onto a field and clicking upload. It also resizes the images so you dont have to resize every image. Very helpfull, if your camera takes pictures larger than 2MB and your PostMax is 2MB.
I have modified a lot of functions on my Site for this. So it will not be of any use for you, but i could try to modify it, to be able to use this for a standard 4Images Site, if there is any intrest in a tool like this???  :mrgreen:

EDIT: Hier noch ein screenshot

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Upload Tool for 4Images written in Java
« Reply #1 on: April 25, 2006, 03:27:15 AM »
What a coinsidnese!
Just yesterday I've started working on a "multi upload" module for 4images, and so far its working fine, the only problem I have at the moment is the JUpload applet I'm using, its so buggy that I had to do work around almost every feature I wanted to use...
My module can be easily adopted to other java uploaders, so maybe we could work out something here ;)

These are the features of a java applet that I'd like to see:
1) the applet can send additional form along with the images to the server
2) accesible parameters via javascript:
 - when files added/removed (this needed in order for javascript add additional fields for these new files into the form)
 - which file(s) selected in the list (this needed in order to show additional fields, such as image name, description, keywords, etc), This feature is not available in JUpload so I had to print all these fealds for each file at the same time - its a mess...
3) applet can retreve server responce and either print the result somewhere or let JS handle it (prefereble), if not, then atleast redirect to a result page.

These are the most important features I'd like to see in the applet, other such as filters for filesize, image dimentions, file types, total size, multilanguage support (can be done with <param>), etc, these are optional...

So, maybe we can work out something here, people have been requesting multiupload for ages now...;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline littleteam

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Littleteam.de
Re: Upload Tool for 4Images written in Java
« Reply #2 on: April 25, 2006, 06:34:13 AM »
So, maybe we can work out something here, people have been requesting multiupload for ages now...;)

trust no-one

Offline JavaUploader

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Upload Tool for 4Images written in Java
« Reply #3 on: April 25, 2006, 10:54:04 AM »
I would be happy to give something back, after using 4images for almost 3 years now.

My problem is, that my PHP is not very good!  :oops:

This is what i have written for the Server-Side so far...

I am pretty shure, this is not very secure!!!  :oops:
But maybe it can show you how it works.

I would like to create a xml for every image and post it together with the image, to upload the UserForm Fields. But i dont know how to read the xml in PHP!!!

Code: [Select]
<?php
define
('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
include(
ROOT_PATH.'includes/constants.php');
global 
$user_info;
$action $HTTP_POST_VARS['action'];
if (
$action == "login") {
$user_name $HTTP_POST_VARS['user_name'];
$user_password $HTTP_POST_VARS['user_password'];

$sql "SELECT user_id 
FROM tpb_users 
WHERE user_name LIKE '"
.$user_name."'";

if($result $site_db->query_firstrow($sql)) {
print_r('loginok');
}
else {
print_r('login failed');
}
$site_db->free_result();
}

if (
$action == "upload") {
$cat_id $HTTP_POST_VARS['cat_id'];
$user_id 1;
$image_name $HTTP_POST_VARS['image_name'];
$image_description "";
$image_keywords "";
$current_time time();
$image_active 1;
$new_name $HTTP_POST_FILE['media_file']['name'];
$new_thumb_name $new_name;
$image_download_url "";
$image_allow_comments 1;
$media_file $HTTP_POST_FILE['media_file'];

$user_info['user_level'] = ADMIN;

include(ROOT_PATH.'includes/upload.php');
    
$site_upload = new Upload();
    
    
$new_name $site_upload->upload_file("media_file""media"$cat_id);
    
/*---------------------------------------
     * Make Thumbnail
     */
    
$src MEDIA_PATH."/".$cat_id."/".$new_name;
    
$dest THUMB_PATH."/".$cat_id."/".$new_name;
    
$do_create 0;
    if (
$image_info = @getimagesize($src)) {
      if (
$image_info[2] == || $image_info[2] == || $image_info[2] == 3) {
        
$do_create 1;
      }
    }
    if (
$do_create) {
      require(
ROOT_PATH.'includes/image_utils.php');
      
$convert_options init_convert_options();
      if (!
$convert_options['convert_error']) {
        
$dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
        
$resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
        
$quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;

        if (
create_thumbnail($src$dest$quality$dimension$resize_type)) {
          
$new_thumb_name $new_name;
        }
      }
    }
if($new_name) {
$sql "INSERT INTO tpb_images
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments)
                VALUES
                (
$cat_id$user_id, '$image_name', '$image_description', '$image_keywords', $current_time$image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments)";
        if(
$site_db->query($sql)) {
echo 'upload ok';
}
else {
echo 'upload failed';
}
$site_db->free_result();       
}
else {
echo 'datei upload failed for '.$new_name.' !';
print_r($_FILES);
}
}
?>