• [MOD] multiupload 5 0 5 1
Currently:  

Author Topic: [MOD] multiupload  (Read 297906 times)

0 Members and 1 Guest are viewing this topic.

Offline rroc

  • Pre-Newbie
  • Posts: 8
    • View Profile
[MOD] multiupload
« on: June 22, 2005, 01:04:20 AM »
[MOD] MultiUpload
- This mod enables the users to add multiple files to a category at once.
- The images will get name and index, ie. "My pet", "My pet 2", "My pet 3",...
- for 4images 1.7.1

The best way to install this is to use the provided files, which give the changes compared to original installation of 4 images.

FILES
Files to be modified: (please take a backup copy of all of these!)
-categories.php  //settings
-categories.html  //To access the new action
-member.php //functionality (ie. looping the default upload method as long as required)

New files:
-member_multiuploadform.html //this is a simplified template for the multiupload
-two buttons... multiupload.gif, and multiupload_off.gif, I attached some as samples.

*NEW* I have included the clean versions of all these files to this post. They contain nothing more than the multiupload mod, it should be easy to integrate from there.


Recommended/required MODS
-auto thumbnailer and auto resizer MODs are highly recommended
-I also use my own EXIF reader and autorotate(according to the EXIF) MODs... these are yet to be released...


INSTALL
------------------------------------

I. SETTING THE VARIABLES

categories.php:

1.
AFTER:
Code: [Select]
$upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
ADD:
Code: [Select]
$multiupload_button = "<img src=\"".get_gallery_image("multiupload_off.gif")."\" border=\"0\" alt=\"MultiUpload images to this Gallery\" />";

2.
AFTER:
Code: [Select]
$upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
ADD:
Code: [Select]
$multiupload_url = $site_sess->url(ROOT_PATH."member.php?action=multiuploadform&amp;".URL_CAT_ID."=".$cat_id);
  $multiupload_button = "<a href=\"".$multiupload_url."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"Upload Multiple files\" /></a>";
 

3.
AFTER:
Code: [Select]
"upload_button" => $upload_button,
ADD:
Code: [Select]
"multiupload_button" => $multiupload_button,


categories.html
4.
REPLACE:
Code: [Select]
{upload_button}
BY:
Code: [Select]
{upload_button} {multiupload_button}





II. FUNCTIONALITY

member.php

1.
REPLACE:
Code: [Select]
if ($action == "uploadimage") {
BY:
Code: [Select]
if ($action == "uploadimage" || $action=="multiuploadimage") {


2.1
REPLACE:
Code: [Select]
if (!$error) {
    // Start Upload
    include(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();

    // Upload Media file
    if (!empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none") {
      $new_name = $site_upload->upload_file("media_file", "media", $upload_cat);
      if (!$new_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
        $uploaderror = 1;
      }
    }
    else {
      $new_name = $remote_media_file;
    }
BY:
Code: [Select]
if (!$error) {
//MULTI FILE UPLOAD
$fileext="";
while(isset($HTTP_POST_FILES['media_file'.$fileext]))
{
include_once(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();

    // Upload Media file
    if (!empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none") {
      $new_name = $site_upload->upload_file('media_file'.$fileext, "media", $upload_cat);
      if (!$new_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
        $uploaderror = 1;
      }
    }
    elseif($action=="uploadimage") {
      $new_name = $remote_media_file;
    }
    else
    {
    $new_name = "";
    break;
    }


2.2  * new *
REPLACE:
Code: [Select]
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none" && !$uploaderror) {
BY:
Code: [Select]
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {


3.1 (NOW START REPLACING ALL THE includes and requires INSIDE THIS ACTION by include_once and require_once)
REPLACE:
Code: [Select]
require(ROOT_PATH.'includes/image_utils.php');
BY:
Code: [Select]
require_once(ROOT_PATH.'includes/image_utils.php');


3.2 do this to change the image names to have index
REPLACE:
Code: [Select]
if ($direct_upload) {
        $sql = "INSERT INTO ".IMAGES_TABLE."
                (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".$additional_field_sql.")
                VALUES
                ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

BY:
Code: [Select]
$imgname = ($fileext!="")?"$image_name $fileext":$image_name;
  if ($direct_upload) {
$sql = "INSERT INTO ".IMAGES_TABLE."
(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".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$imgname', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";


4.
REPLACE:
Code: [Select]
include(ROOT_PATH.'includes/search_utils.php');
BY:
Code: [Select]
include_once(ROOT_PATH.'includes/search_utils.php');


5.
REPLACE:
Code: [Select]
include(ROOT_PATH.'includes/email.php');
BY:
Code: [Select]
include_once(ROOT_PATH.'includes/email.php');


6.
REPLACE:
Code: [Select]
$msg .= $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$new_name.")";BY:
Code: [Select]
      $msg .= $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$new_name.")<br>";
7. (almost over... )
REPLACE:
Code: [Select]
      $content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

if ($action == "uploadform") {
BY:
Code: [Select]
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    $good=1;
  }
  else {
  //Atleast 1 multifile succeeded.
  if(count($HTTP_POST_FILES) && $good==1)
  {
  $action = "multiuploadform";
  break;
  }
  else
  {
  $action=($action=="multiuploadimage")?"multiuploadform":"uploadform";
  $sendprocess = 1;
  break; //break the while if any image upload fails
  }
  }
  $fileext=($fileext=="")?2:$fileext+1;
  }//end while
  }//end if
    else
    {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }//end upload action
 
  //Show the form
if ($action == "uploadform" || $action == "multiuploadform") {

8. to parse the correct html...
REPLACE:
Code: [Select]
$content = $site_template->parse_template("member_uploadform");BY:
Code: [Select]
  if($action == "multiuploadform" || $action=="multiuploadimage")
    {
    $content = $site_template->parse_template("member_multiuploadform");
    }
    else
    {
    $content = $site_template->parse_template("member_uploadform");
  }


FINALLY...

III. CREATE A PAGE FOR MULTIUPLOAD FORM 'member_multiuploadform.html'
- download the file from below and copy it to your template folder (of course rename to member_multiuploadform.html)
- you may un-comment more file items, if you expect the users to download smaller files. For me 5 is quite enough when uploading jpgs directly from 5MP digital camera... (I  use the auto thumbnailer and auto resizer), but for photos from my 2MP camera I can use even 10...
- 4 images will just give (a bit misleading though), timeout error, if one tries to add too many images at once... complaining that you have invalid password(or something I can't recall...).
- Please edit this HTML to use your current locals (actually, you should add some variables to your language main.php -file...), I was too busy to do that.


...READY. Now starts the testing. :) (at first it is good to check that the 'normal' upload works as it used to... )


22 June 2005 CORRECTED the steps II.2 and II.7 were changed
23 June 2005 CORRECTED I fixed step II.2, incorrectly, leaving out the ".$fileext"-extension when checking the input files. And added a new II.2.2, to enable the auto thumbnailing...
26 July 2005 ADDED attachments of 'clean' multiupload files.
27 July 2005 UPDATED the instructions to match the provided files.
« Last Edit: June 22, 2005, 12:34:10 PM by Jan »

Offline MustardGT

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: [MOD] multiupload
« Reply #1 on: June 22, 2005, 04:31:08 AM »
I'm getting:

"Template Error: Couldn't open Template ./templates/4dark/media/.html"

Any ideas how to fix that?

Offline rroc

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] multiupload
« Reply #2 on: June 22, 2005, 11:59:50 AM »
Thanks for bringing that up... It seemed I had some error in the above. I have commented out the possibility to use remote files in my own installation, and while converting to the original form I had some parenthesis errors...  :oops:

Now the MOD above is corrected...

[27 July 2005] removed the correction details, as they refer to older version

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] multiupload
« Reply #3 on: June 23, 2005, 07:14:47 AM »
Is there a demo???
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline rroc

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] multiupload
« Reply #4 on: June 23, 2005, 08:03:24 AM »
Sorry no demo as the gallery is meant for my friends private use, but I'll give you 4 screenshots.

1: before... here the multiupload is clicked
2: multiupload form
3: after the upload, file names are shown, and also all the images. (here I have another mod to show the gallery name as well, but never mind...)
4: here all the images are added to the category also shown in 1.

(I hope you are able to see something, as the 124kb limit I had to downgrade them a bit)

Offline blackbeatclub

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] multiupload
« Reply #5 on: June 23, 2005, 03:07:26 PM »
Hi

first of all thx for this nice mod i was searching for something like this for a long time.

The Mod seems to work fine but when i want to upload the pictures then he only upload the
1st picture. (see the screenshot 4more details)



"Fehler beim Upload der Bild-Datei:" means that an error occured while uploading the file (file2).
But first Picture has been uploaded without problems.

Could you please try to help me?
Do you know what i did wrong?

Thx in advanced



Offline maziggy

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [MOD] multiupload
« Reply #6 on: June 23, 2005, 03:31:07 PM »
Nice MOD ;-) Why is it not possible to type in a description for each image to be uploaded ?

Cheers, Martin

Offline rroc

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] multiupload
« Reply #7 on: June 23, 2005, 04:26:28 PM »
blackbeatclub, thanks for testing this out... I still had some copy-paste errers... to fix, take a look at the last line of II.2.1, and also do the new II 2.2. ... Now, it should work.

maziggy, I thought of that, but for my purposes this is better... as I can easily add many photos without having to type the description and the name for each of them separately. I can just say that holiday in China, and if there is some special picture, I can comment it later in more detail.

However, it is fairly easy to do that if you need it...

[27 July 2005] EXPLANATION in my newest post.

Offline blackbeatclub

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] multiupload
« Reply #8 on: June 23, 2005, 04:49:11 PM »
blackbeatclub, thanks for testing this out... I still had some copy-paste errers... to fix, take a look at the last line of II.2.1, and also do the new II 2.2. ... Now, it should work.

hi thx 4 help but it doesnt change anything.
the error is still there - no change.

the error must be in the member.php right? ok here is my member.php perhaps you can find out whats my mistake.
Just Rename the member.zip to member.php.

thank you


Offline rroc

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] multiupload
« Reply #9 on: June 23, 2005, 05:35:16 PM »
Hmmmmm! I did compare the files, and there was one difference that I didnt document... again(!!!)... Unfortunately it does not affect you in any way... It only makes the image names different...  :cry:

REPLACE:
Code: [Select]
      if ($direct_upload) {
        $sql = "INSERT INTO ".IMAGES_TABLE."
                (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".$additional_field_sql.")
                VALUES
                ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

BY:
Code: [Select]
  $imgname = ($fileext!="")?"$image_name $fileext":$image_name;
  if ($direct_upload) {
$sql = "INSERT INTO ".IMAGES_TABLE."
(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".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$imgname', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

I'm not sure about the possibility of conflict with the "Image Annotation MOD", you are using? I don't have that... Another thing is what I have done, is that I don't use those remote upload files at all. (I have commented thos away as well)

When I'll have the time, I'll have to install a clean 4images just for the mod development purposes... It's a bit difficult to see things when there are many overlapping MODs.

I will include my member.html, though it has some code for my MOD for EXIF and automatic rotation... But it could be of help to see the differences in that whole critical uploading section beginning from:

"if ($action == "uploadimage" || $action=="multiuploadimage") {"


So you still have the same problem, that the first image is uploaded correctly, but the second one, etc ain't?  I had this when I was developing this as well... And atleast one time I had to log off the current section, and to try again... MAybe it stores some of the data into cache... But some problem there seems to be anyhow.  :?

I'll get back to it, now I have a vacation... and I'll be away for a while...

[Modified] 26.7. removed the attachment, as it had way too much in there. The correct version is attached in the main mail.

Offline MustardGT

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: [MOD] multiupload
« Reply #10 on: June 25, 2005, 01:30:13 AM »
Yep, that fixed it and it works perfectly now man. Very excellent mod. I'm glad to see that someone finally tackled the tast and got it right. Congrats!

Thanks for the great work.

Offline benzo

  • Hero Member
  • *****
  • Posts: 748
  • El que nada duda, nada sabe. :-)
    • View Profile
Re: [MOD] multiupload
« Reply #11 on: June 26, 2005, 02:02:55 PM »
Great Mod  8)
It would be possible to upload to different categories and with different names ?

Regards.
¡ Antes de actualizar o modificar el script, realiza una copia de seguridad de todos los archivos y datos !

Tenemos una pequeña faq en español, también la faq oficial ( en inglés  ) y un buscador muy hermoso

Offline abifotos

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [MOD] multiupload
« Reply #12 on: June 28, 2005, 09:22:39 PM »
hey blackbeatclub!

did you find a solution for the multiupload problem?
I got the same with 4images 1.7.1...

thanks!
Benny

Offline ctforums

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [MOD] multiupload
« Reply #13 on: June 28, 2005, 11:46:08 PM »
Nice MOD ;-) Why is it not possible to type in a description for each image to be uploaded ?

Cheers, Martin


Hi maziggy!
Did you manage to get the descriptions working for each image?  I'm struggling on this one. Cheers.

Offline abifotos

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [MOD] multiupload
« Reply #14 on: June 29, 2005, 12:59:20 AM »
Which version of 4images do you use to use this extension?
I tried it with 1.7.1 and had no luck ... do I habe any chances to get this problem solved with version 1.7.0 ?