forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Uploading => Topic started by: Bish on August 28, 2005, 01:05:57 am

Title: Upload java applet (Beta)
Post by: Bish on August 28, 2005, 01:05:57 am
Hi.
I've created a modification of Coppermine, which can make the upload procedure a bit easier when uploading pictures. The upload is performed by a Java-program, and is thus more userfriendly than the original javascript-user interface. The program is still very much in beta, but has reached a usable state, and I'm now interested in some feedback from users of Coppermine, to see if it is worth pursuing and developing further.

I created a screenshot of the applet, so that you can get an initial impression of the functionality (http://aasted.org/CMIU-screen.jpg).

Unfortunately, I can't offer a public demonstration of the applet, as my Gallery is private to my family, and thus I'm not interested in having a public link to it anywhere.

The following are instructions that should enable you to try and set up the applet in your own installations. Unfortunately, the applet requires that Java 1.5 is installed on the machine, which I fear is a rather rare occurrence for most users. Find it at http://java.com/getjava .

Install instructions:
1. Download http://aasted.org/CMImageUploader.zip and unpack it.
2. Edit the file upload2.php. Modify the "uploadURL", "nextPage" and "Domain"-parameters to the applet, so that they match your installation.
3. Upload the 3 files to the root of your Coppermine-directory.
4. Log in to your gallery.
5. Go to the upload2.php page. Accept the warning that the applet should be trusted. (This will give the applet full access to the contents of your harddisk, so I guess you'll just have to hope that I'm not trying to con you.  ;) ).
6. Use the applet to select a number of pictures. When you're done, press "Start upload".

After this, the applet should (hopefully) present you with the page that is normally used to import images uploaded by FTP. I originally tried to interface with the normal upload-page, but this proved impossible, as it was expecting some posted parameters that I could not provide from the applet.

I'll now list some of the improvements I would like to make to the applet, if there is sufficient interest in better versions.

1. Make it recover gracefully from network errors. How it reacts to network errors have not been fully explored, but I imagine that it isn't pretty. :)

2. Make the upload-page detect whether a Java-VM of the correct version is available. If this is not the case, revert to old, form-based upload-method. Perhaps leave some text explaining the advantages of getting Java.

3. Do some prefetching of "likely pictures to be previewed next" in the applet. This will improve the perceived load-time when going through each picture in the directory.

4. Integrate the applet with the general UI of Coppermine. (Preferably, I would like some assistance with this, as I'm not very well-versed in your code-base).

5. Make a stand-alone application with the same interface, so that people can run it outside the browser. (Should be extremely easy).

6. Dynamically generate the parameters to the applet.

Looking forward to receiving feedback on this.
Title: Re: Upload java applet (Beta)
Post by: kegobeer on August 28, 2005, 01:36:55 am
I made a few alterations to your upload2.php file so no modifications are necessary for the user:

Code: [Select]
<?php
// Confirm we are in Coppermine and set the language blocks.
define('IN_COPPERMINE'true);
define('UPLOAD_PHP'true);
define('DB_INPUT_PHP'true);
define('CONFIG_PHP'true);

// Call basic functions, etc.
require('include/init.inc.php');
require(
'include/picmgmt.inc.php');

// Some placeholders.
$customize CUSTOMIZE_UPLOAD_FORM;
$user_form USER_UPLOAD_FORM;
$allowed_URI_boxes NUM_URI_BOXES;
$allowed_file_boxes NUM_FILE_BOXES;
$url str_replace("http://","",$CONFIG['ecards_more_pic_target']);
$urlComponents explode("/",$url);
$domain 'http://' $urlComponents[0] . '/';
$url $CONFIG['ecards_more_pic_target'];

// Check to see if user if the admin.  Quit with an error if he cannot.
if (!USER_IS_ADMIN) {
    
cpg_die(ERROR$lang_errors['perm_denied'], __FILE____LINE__);
}

// Globalize $CONFIG.
global $CONFIG$lang_upload_php$user_form$max_file_size;

// Generate a sufficiently unique and short identifier for the new directory containing the uploaded images.
// The risk of name collisions with this scheme is so small that I will not bother with it.
$id strtoupper(base_convert(sha1(rand()), 1636));

echo 
'<center>
<APPLET CODE="net.aasted.imageupload.gui.ImageUploadApplet" ARCHIVE="ImageUploader.jar" WIDTH="800" HEIGHT="600"">
<param name="uploadURL" value="'
$url'fileupload.php?dir='$id'" />
<param name="nextPage" value="'
$url'searchnew.php?startdir='$id'" />
<param name="domain" value="'
$domain'" />';
$i 0;
foreach ($_COOKIE as $key => $cookie) {
echo '
<param name="cookie'
$i'" value="'$key':'$cookie'" />';
$i++;
}
echo 
'
</APPLET>
</center>'
;
?>

This is also just for Coppermine admins, correct?  Since normal users do not have permission to access searchnew.php, you need to check for the admin rights before allowing upload2.php to execute.  I changed the code to check for admin status instead of the ability to upload.  This same check needs to be done in fileupload.php.  If this is incorrect, please let me know.

You should also look at examples of how mkdir and chmod are used (db_input.php) and have your mkdir command do the same.

Your $_GET variables need to be sanitized - removing illegal characters and potentially harmful code is a must before processing anything.

The interface is very nice!  Great job with the java applet.  Overall this will be a very nice mod!  Great work so far.
Title: Re: Upload java applet (Beta)
Post by: kegobeer on August 28, 2005, 02:22:54 am
After a quick look, I'm sure it's possible to allow regular members to use this interface also.  Just a matter of checking for admin status, and assigning the correct directory and nextPage variables.  An edit of fileupload.php also to check for collisions and rename if necessary.

Also, if user uploads are allowed, more checks are required to take into account file upload limits, quotas, etc.

I'll look into it when I get a chunk of free time.
Title: Re: Upload java applet (Beta)
Post by: snork13 on August 28, 2005, 03:38:30 am
Very COol mod!  I got it working, thanks for sharing...the interest of regular user is promising :)

-snork13


1 bug I have found? when i go into a folder with images (.jpg) with file type set to "Image File" they don't show up, I have to switch to "All Files"
Title: Re: Upload java applet (Beta)
Post by: Joachim Müller on August 28, 2005, 01:58:52 pm
Coding discussion for this mod continues in the thread Java Upload applet (http://forum.coppermine-gallery.net/index.php?topic=21241.0) (only accessible for devs and contributors, regular users can not access this thread). We'll update this thread as soon as there is actual code that is recommended for live use.
Title: Re: Upload java applet (Beta)
Post by: Bish on December 29, 2005, 04:22:05 pm
I've now made the first "formal" release of the Java upload mod. You can find it at http://aasted.org/coppermine/ (http://aasted.org/coppermine/).

Notable improvements since I last posted are:

Hoping to get a lot of feedback from interested users. Enjoy.

-- Henrik
Title: Re: Upload java applet (Beta)
Post by: kegobeer on December 29, 2005, 05:52:51 pm
You should discontinue 1.3 development and focus on 1.4.
Title: Re: Upload java applet (Beta)
Post by: Bish on December 30, 2005, 01:05:48 am
You should discontinue 1.3 development and focus on 1.4.

I just made a quick test-installation of 1.4, and it turns out that the program is compatible with 1.4. I'll update the webpage immediately.

-- Henrik
Title: Re: Upload java applet (Beta)
Post by: Joachim Müller on December 30, 2005, 08:54:53 am
flagged this thread accordingly.
Title: Re: Upload java applet (Beta)
Post by: xyster on April 11, 2006, 07:41:57 am
Ok, i have read this site.

I really love the whole idea here, i had been hoping this would come out for quite some time since using coppermine, i have been using coppermine effectively now for a while.

i am running 1.4.x version of coppermine.

I Read that you were looking for feedback on the Java Applet. Well i think its fantastic, looks great and is really easy to follow.

Though i just added it in, the applet runs

www.mysite.com/gallery/upload2.php

thats the link i use, im sry i dont want to give my actual site away unless i have to as some pictures are personal on the site.

To go on, the java applet loads no problems, i can select the images, the loading bar goes.. reaches 100% then i get redirected to the "searchnew.php?startdir=8V3F4MH3MLFPGK8SSGCGSKKKCGCG0C0"

on the page i see the following

*************************
List of new files


No new file was found
**********************


And that is all i see, how come it says there are no new files, it said sumwhere i needed to set a new album for it? Do it? What to i edit to do this?


Also, i Tried to remove this as i was having issues with normal uploads once i put this on. How come i am now having problems with my normal upload.php file?

i didnt touch anything, all i did was add the 3 files that were in the rar'd file on the link provided and used the upload2.php to test the javascript.. Now wen i try and upload a file using normal upload.php with or without the added files on my server i cannot seem to do it, once it says the file was succesfully upload click to continue (where u move onto the screen where u choose the caption catergory etc) for the file it just sits there on a white screen. Why is this happening.. i didnt think nething was edit'd I only need to kno how to fix this if i cant get the upload to work correctly

For some reason only jpeg files currently arent working, it was tested using a .png file and the file was succesful using the normal upload.php

P.S This method creates a new Folder every time in the albums section for the batch add files, this will result in very large amounts of files been added eventually wont it? Is there a way for the folder to be deleted and the files moved to the general folder once this is done. I kno this isnt the norm with the batch add files as i have used it many times to add 100+ foto's and they stay in there specific folders.
Title: Re: Upload java applet (Beta)
Post by: Bish on April 16, 2006, 11:45:46 am
Hi Xyster.
Apologies for my slow reply, I was on vacation until yesterday.

One thing I've failed to mention with regards to the uploader, is that it requires the user using it to be administrator. I may change this at some point by releasing an optional, modified version of the batch-upload-receiving file. Perhaps your problem comes from uploading through a user that is not administrator.

If possible, could you use your ftp-client and check to see if the directory 8V3F4MH3MLFPGK8SSGCGSKKKCGCG0C0 contains the uploaded files? This would make it a lot easier to determine in which part of the upload-process something goes wrong.

Regarding the moving of uploaded files, there are no current plans to allow this. From the perspective of a user browsing the gallery, it doesn't make any difference where the files are placed, so I consider this a very low-prioritized "nice-to-have"-change. Perhaps it's functionality that will be built in to the standard CM-distribution at some point.

I'm rather perplexed that your normal upload-procedure seems to have been affected. As you mention yourself, upload.php is not touched at all by this mod, so I think that it's likely not this mod causing the problems.

 Regards
 Henrik
Title: Re: Upload java applet (Beta)
Post by: xyster on April 25, 2006, 08:41:07 am
Yes, it was under my account i did the upload, it is ok that it was a slow reply i dont mind, hope ur holiday was great.

I have administrator rights. The randomly named folders were created each time i used the upload java app. Each time the folders were empty.

Yes, the folder isnt worth the bother i agree as it would require a lot of extra coding im sure, im no coding expert but i kno a lil about FTP.

I ran a new test, uploaded the files again to remove any possible things that could have caused any random errors. I uploaded a small jpeg file, i refreshed FTP sure enuf the new folder is there. now, the folder permissions are 755. doesnt the folder permisions need to be set to 777 for an upload to come in from elsewhere?


Also, another note, for some reason it only seemd to affect the admins aswell, thoguh just as odd the problem stopd lol... i dont kno y, probably just a random glitch im sure.


For further details dont hesitate to ask as i kno this is still in the Beta Phase and i am more than willing to help get this program running as smoothly as possible as i think its one of the few features the coppermine gallery is missing.

P.S Sorry for the late reply aswell, i had problems accessing this site, it seems to go down quite often at random intervals? Mite just be me, lol
Title: Re: Upload java applet (Beta)
Post by: Kyyhky on May 21, 2006, 08:34:23 am
Awsome work Bish  8)
works like a charm!

if it worked with regular users it would be perfect...  ;)
Title: Re: Upload java applet (Beta)
Post by: diavol on June 07, 2006, 10:23:31 pm
Hey, bish, this applet is fantastic, works like advertised.  The only inconvience is the random directory name it creates... is there a way to modify upload2.php to promt for the directory name that you want to upload the pics to?
Title: Re: Upload java applet (Beta)
Post by: Bish on June 07, 2006, 10:32:40 pm
@diavol:
The random directory name is actually a security measure, so I'd recommend against changing it.

However, if you want it to be differently generated or user-selected, you should modify the upload2.php-file. The two applet-parameters "uploadURL" and "nextPage" contain the name of the directory that will be created. If you change these parameters, the name of the directory will be named accordingly.

 Regards
 Henrik
Title: Re: Upload java applet (Beta)
Post by: diavol on June 07, 2006, 11:53:49 pm
Bish, thanks for the quick reply, I've tried puting something like this

Code: [Select]
$id = prompt('<?php echo T_('Save to'?>: ', ' ');to define "id", but that didn't fly, I'm such a php noob that it's not even funny, what's the easiest way for me to implement this?
Title: Re: Upload java applet (Beta)
Post by: Kyyhky on June 09, 2006, 06:15:21 pm
good idea diavol, if you get that to "fly" I might use it too... Sorry but I don't know php at all so I can't help you with the coding...

I still think the normal user upload ability would be the most important feature. After all, the normal batch add for admins is quite good, but normal users can only use single file upload wich is practically useless...and I haven't been ably to use xp's publish feature since I integrated to phpbb...so I would really need the user mode to java upload applet ;)

Title: Re: Upload java applet (Beta)
Post by: keroliukas on June 12, 2006, 10:42:32 pm
awesome mod!!! TY  ;D
but how do i enable it for regular users? i commented the admin only lines, it says everything is ok, but it doesn't add :( ???
Title: Re: Upload java applet (Beta)
Post by: gwendolyn on July 12, 2006, 04:40:37 pm
huhu :):)
great mod and applet...
made a small modified version of the php's
so evry user will upload its pictures to theis normal /userpics/userfolder
had made it first uploading in a folder called their username but cause of
already being pictures of some users in their userpics folder i thought this could be more usefull...

fileupload.php
Code: [Select]
<?php
/*
// Confirm we are in Coppermine and set the language blocks.
define('IN_COPPERMINE', true);
define('UPLOAD_PHP', true);
define('DB_INPUT_PHP', true);
define('CONFIG_PHP', true);

// Call basic functions, etc.
require('include/init.inc.php');
require('include/picmgmt.inc.php');

// Some placeholders.
$customize = CUSTOMIZE_UPLOAD_FORM;
$user_form = USER_UPLOAD_FORM;
$allowed_URI_boxes = NUM_URI_BOXES;
$allowed_file_boxes = NUM_FILE_BOXES;

// Check to see if user can upload pictures.  Quit with an error if he cannot.
/*
if (!USER_CAN_UPLOAD_PICTURES) {
    cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
}
*/
/*
if (!isset($_GET["dir"])) {
cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
}
*/

$dir "albums/" $_GET["dir"] . "/";

if (!
file_exists($dir)) {
mkdir($dir);
chmod($dir0777);
}

$filename $dir $_FILES['file_upload']['name'];

if (
file_exists($filename)) {
$filepart $dir $_FILES['file_upload']['name'] . ".part";
// This is the next part of the file, and should thus be appended to the existing file.
if (move_uploaded_file($_FILES['file_upload']['tmp_name'], $filepart)) {
$part fopen($filepart"r");
$dest fopen($filename"a");
// Possibility that this is a bit hard on the server. Should perhaps be changed to a loop to
// preserve memory.
fwrite($destfread($partfilesize($filepart)));
fclose($part);
fclose($dest);
// Delete partial file.
unlink($filepart);
} else {
slog("Failure while moving partial file.");
}
} else {
move_uploaded_file($_FILES['file_upload']['tmp_name'], $filename);
}
chmod($filename0755);

?>

ulpoad2.php
Code: [Select]
<?php
// Confirm we are in Coppermine and set the language blocks.
define('IN_COPPERMINE'true);
define('UPLOAD_PHP'true);
define('DB_INPUT_PHP'true);
define('CONFIG_PHP'true);

// Call basic functions, etc.
require('include/init.inc.php');
require(
'include/picmgmt.inc.php');

// Some placeholders.
$customize CUSTOMIZE_UPLOAD_FORM;
$user_form USER_UPLOAD_FORM;
$allowed_URI_boxes NUM_URI_BOXES;
$allowed_file_boxes NUM_FILE_BOXES;
$url str_replace("http://","",$CONFIG['ecards_more_pic_target']);
$urlComponents explode("/",$url);
$domain 'http://' $urlComponents[0] . '/';
$url $CONFIG['ecards_more_pic_target'];

// Check to see if user can upload pictures.  Quit with an error if he cannot.
if (!USER_CAN_UPLOAD_PICTURES) {
    
cpg_die(ERROR$lang_errors['perm_denied'], __FILE____LINE__);
}

// Globalize $CONFIG.
global $CONFIG$lang_upload_php$user_form$max_file_size;

// Generate a sufficiently unique and short identifier for the new directory containing the uploaded images.
// The risk of name collisions with this scheme is so small that I will not bother with it.
//$id = strtoupper(base_convert(sha1(rand()), 16, 36));
//$user_name = get_username(USER_ID);
//$id = $user_name;
$filepath $CONFIG['userpics'] . (USER_ID FIRST_USER_CAT);
$id $filepath;

echo 
$user_name;

// Determine largest allowed filesize.
if ( (int) ini_get('upload_max_filesize') < (int) ini_get('post_max_size') ) {
$max_file ini_get('upload_max_filesize');
} else {
$max_file ini_get('post_max_size');
}
$max_file = ((int) $max_file) * 1024 1024;

echo 
'<center>
<APPLET CODE="net.aasted.imageupload.gui.ImageUploadApplet" ARCHIVE="ImageUploader.jar" WIDTH="800" HEIGHT="600">
<param name="uploadURL" value="'
$url'fileupload.php?dir='$id'" />
<param name="nextPage" value="'
$url'searchnew.php?startdir='$id'" />
<param name="domain" value="'
$domain'" />
<param name="maxSize" value="'
$max_file'" />';
$i 0;
foreach ($_COOKIE as $key => $cookie) {
echo '<param name="cookie'$i'" value="'$key':'$cookie'" />';
$i++;
}
echo '</APPLET></center>';

?>


but got a small problem if uploading only one picture,
after upload in batch add there is any picture shown until refresh :/:/
anyone got an idea to fix this,
or better said to set a small break until refresh to batch add page?!
thx and hope its usefull this mod :):) made by me :):)
would be great if there will be an admin panel where u can choose either to upload to userpicsfolder,
crypted or folders by username :):)
and one thing i dont get to work...
how to integrate the applet so that its loaded in the maintable of the gallery :/:/
would be great if anyone could help :):)
thx :):)
Title: Re: Upload java applet (Beta)
Post by: Farnsi on September 15, 2006, 10:36:53 pm
Hey Bish, this is a really great applet! Almost everything works perfect, there is just a little i'm missing.
Is there by any chance the possibility to let normal, registered users use this applet?
Greetings
Title: Re: Upload java applet (Beta)
Post by: etienne_sf on December 08, 2006, 10:54:42 am
Coding discussion for this mod continues in the thread Java Upload applet (http://forum.coppermine-gallery.net/index.php?topic=21241.0) (only accessible for devs and contributors, regular users can not access this thread). We'll update this thread as soon as there is actual code that is recommended for live use.


Hi,

I understand of this (old) message, that you're working in integration of an upload aplet within coppermine.

  As I worked on the jupload mods (as you know, see http://forum.coppermine-gallery.net/index.php?topic=35309.0 (http://forum.coppermine-gallery.net/index.php?topic=35309.0)), I'm interested in helping in this thread.

  I think that jupload add interesting things:
- picture rotation
- picture resizing before upload (allows upload of 'big' picture to a server having limited upload maximum size)
- Already contains the php coppermine integration
- Already used by several users
- the php part allows a really simple album and picture manipulation. My users are 'simple' ones: they are lost with the album creation page! But they can use the jupload.php page I've build.

Regards
Etienne
Title: Re: Upload java applet (Beta)
Post by: Joachim Müller on December 08, 2006, 05:52:26 pm
We'd love to see your suggestions, especially since none of the current dev team members is a Java expert afaik. You (as member of the contributors group) have access to the coding discussion thread http://forum.coppermine-gallery.net/index.php?topic=21241.0 mentioned above. Let's discuss details there.
Title: Re: Upload java applet (Beta)
Post by: ncvettes on January 26, 2007, 09:54:19 pm
Gwendolyn.... Have you received any response to your questions? I agree with others that java upload is a great idea, but if only for admins it's not worth the effort to me. And oncec GauGau took this to a private discussion area things seemed to stop as far as I can tell.  :'(
Title: Re: Upload java applet (Beta)
Post by: etienne_sf on January 27, 2007, 09:49:02 am
Gwendolyn.... Have you received any response to your questions? I agree with others that java upload is a great idea, but if only for admins it's not worth the effort to me. And oncec GauGau took this to a private discussion area things seemed to stop as far as I can tell.  :'(

Take a look to the jupload plugin, available here :
http://forum.coppermine-gallery.net/index.php?topic=35309.0

Etienne
Title: Re: Upload java applet (Beta)
Post by: ncvettes on January 27, 2007, 03:42:11 pm
Take a look to the jupload plugin, available here :
http://forum.coppermine-gallery.net/index.php?topic=35309.0

Etienne

Thanks, etienne. I installed it and it works great!  ;D  I was confused at first since this is a different script (I think) from one I saw earlier (java window had preview pics available prior to adding them to the upload list). Yours works very well though. Tnx for your time.
Title: Re: Upload java applet (Beta)
Post by: saitanay on October 24, 2007, 12:54:22 am
can some1 tell me what are the modifications neede for upload2.php?
Title: Re: Upload java applet (Beta)
Post by: etienne_sf on October 24, 2007, 10:29:32 am
can some1 tell me what are the modifications neede for upload2.php?

You should go here:
http://forum.coppermine-gallery.net/index.php?topic=43432.0 (http://forum.coppermine-gallery.net/index.php?topic=43432.0)

  It's a fully functional plugin, not a beta one !

Etienne
Title: Re: Upload java applet (Beta)
Post by: Joachim Müller on October 26, 2007, 07:10:18 pm
Locking this thread.