forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Uploading => Topic started by: Garibaldi on April 17, 2009, 10:54:09 pm

Title: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on April 17, 2009, 10:54:09 pm
I'd like to announce the release of the "Formats Upload" MOD for Coppermine 1.4.x. I needed a solution that would allow me to associate a zip file with each image on my site. This way I could include other files related to that image like an editable photoshop version, a text file with information about that image, etc. This modification adds that same functionality to your Coppermine install. It adds a new button on the Upload page, Edit File page, or Edit Files page. You can select the zip (or other file type) to associate with your image and it is added to the Custom User Field 1 and thus appears right below your image in your gallery for easy access. Here's an example:
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_final.JPG

When you upload a file you're presented with this new "Add Formats" button. This same button appears when you click Edit on a picture or edit all the pictures in an album. When you click this button, a new window pops up where you can upload your associated file. Once finished hit done and it will be put automatically into the Other Formats field. You can then save your picture.
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload.JPG

http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload1.JPG

http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_upload2.JPG

Here's an example of the similar functionality when you edit an image:
http://wiscollectorcar.com/photogallery/albums/userpics/10301/normal_edit_file.JPG

In addition, if you batch upload pictures, this modification will look for a .zip file in the formats_upload directory that has the same filename as each picture in your batch upload. If that file exists, it will be added automatically to each photo in the batch upload.

I've attached the zip of the files with install instructions.

*NEW* - version 1.2.x will delete the uploaded zip file associated with an image when you delete the image - to upgrade simply follow these instructions (http://forum.coppermine-gallery.net/index.php/topic,59073.msg301940.html#msg301940)

A support topic for this modification is available on the Support Board (http://forum.coppermine-gallery.net/index.php/topic,60768.0.html)

2009-07-30- version 1.2.0 now deletes the uploaded file when deleting a picture
2009-06-30- version 1.1.1 bugfix to correct the slashes in the upload URL for Windows servers

2009-06-01- version 1.1.0 added unique filenames for uploads

2009-04-17- version 1.0.0
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on April 17, 2009, 10:55:24 pm
###############################################

## MOD Title: Formats Upload

## MOD Author: Garibaldi (Garibaldi@wiscollectorcar.com) http://www.wiscollectorcar.com

## MOD Description: Allows you to associate a file with each image in your gallery, e.g. a zip archive of files related to that image

## MOD Version: 1.1.1

## Installation Level: Easy

## Installation Time: 10 minutes

## Files To Edit: 7

##   upload.php

##   editpics.php

##   editOnePic.php

##   include/picmgmt.inc.php

##   lang/english.php

##   formats_upload.php

##   formats_helper.php

## Included Files:

##   formats_upload/

##   images/formats_upload.png

##   js/fileprogress.js

##   js/handlers.js

##   swfupload.js

##   swfupload.queue.js

##   swfupload.swf

##   swfuploadbutton.swf

## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2

##############################################################

## Author Notes:

## This modification uses the http://swfupload.org/ upload script

##############################################################

## MOD History:
## 2009-06-30- version 1.1.1 bugfix to correct the slashes in the upload URL for Windows servers

## 2009-06-01- version 1.1.0 added unique filenames for uploads

## 2009-04-17- version 1.0.0

##############################################################

## Before Adding This MOD To Your Coppermine install, You Should Back Up All Files Related To This MOD

##############################################################



#

#-----[ IN COPPERMINE ]---------------------------------

#

   Log in as an administrator and go to Config. Expand the section

   "Custom fields for image description (leave blank if unused)" and

   enter a name in "Field 1 name" like "Other Formats". Save the new

   configuration



#

#-----[ UPLOAD ]----------------------------------------

#

   Upload all files in this package to you Coppermine root directory



#

#-----[ OPEN ]------------------------------------------

#

   upload.php



#

#-----[ FIND ]------------------------------------------

#

       // Create a text box.
   

   echo <<<EOT   



#

#-----[ BEFORE, ADD ]-----------------------------------

#

   // s garibaldi

   global $lang_upload_php;

   if ($text == $CONFIG['user_field1_name']) {

      $text = $text . ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'user1\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_upload_php['other_formats_button'] . '" class="button" /> &nbsp; ';

   }

   // e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   editpics.php



#

#-----[ FIND ]------------------------------------------

#

    echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                        $text

        </td>

        <td width="100%" class="tableb" valign="top">

                <input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput" />

                </td>

        </tr>



EOT;



#

#-----[ REPLACE WITH ]----------------------------------

#

   // s garibaldi

   global $CONFIG, $lang_editpics_php;

   if ($text == $CONFIG['user_field1_name']) {//ereg($CONFIG['user_field1_name'], $text)) {

      $text = $text . ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'' . $name . '\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_editpics_php['other_formats_button'] . '" class="button" /> &nbsp; ';

   }



    echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                        $text

        </td>

        <td width="100%" class="tableb" valign="top">

                <input type="text" style="width: {$field_width}%" id="$name" name="$name" maxlength="$max_length" value="$value" class="textinput" />

                </td>

        </tr>



EOT;

   // e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   editOnePic.php



#

#-----[ FIND ]------------------------------------------

#

echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                {$CONFIG['user_field1_name']}

                </td>

                <td width="100%" class="tableb" valign="top">

                                <input type="text" style="width: 100%" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />

                        </td>

        </tr>

EOT;   



#

#-----[ REPLACE WITH ]----------------------------------

#

// s garibaldi

global $lang_editpics_php;

$other_formats = ' &nbsp; &nbsp; <input type="button" onclick="window.open(\'formats_upload.php\',\'user1\',\'status=0,toolbar=0,location=0,menubar=0,height=300,width=420,resizable=1\')" value="' . $lang_editpics_php['other_formats_button'] . '" class="button" /> &nbsp; ';

echo <<<EOT

        <tr>

            <td class="tableb" style="white-space: nowrap;">

                {$CONFIG['user_field1_name']}{$other_formats}

                </td>

                <td width="100%" class="tableb" valign="top">

                                <input type="text" style="width: 100%" id="user1" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />

                        </td>

        </tr>

EOT;

// e garibaldi



#

#-----[ OPEN ]------------------------------------------

#

   include/picmgmt.inc.php



#

#-----[ FIND ]------------------------------------------

#

    $image = $CONFIG['fullpath'] . $filepath . $filename;

    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;

    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;



#

#-----[ AFTER, ADD ]------------------------------------

#

   // s garibaldi

   

   // ******************** //

   // *** START CONFIG *** //

   // ******************** //

   $user1_path = "/var/htdocs/cpg14x/formats_upload/";   // NOTE: even if you are using Windows, use forward slashes "/" for paths - e.g. C:/windows/

   $user1_url = "http://mycpgroot.com/formats_upload/";

   $extension = "zip";

   // ******************** //

   // **** END CONFIG **** //

   // ******************** //

   

   $user1_file = substr($filename, 0, strlen($filename)-3) . $extension;

   // check to see if user1 not set already and exists in the specified dir

   if(($user1 == '') && is_file($user1_path . $user1_file)) {

         $user1 = $user1_url . $user1_file;

   }

   // e garibaldi



#

#-----[ NOTE ]------------------------------------------

#

   Edit the lines the lines after START CONFIG and before END CONFIG,

   adjusting the path of the upload folder for the files. This folder should

   not be inside your Coppermine albums folder. Its permissions may also need

   to be adjusted to 777 to allow upload. You can also adjust the type of files

   that can be uploaded. By default only .zip files are allowed



#

#-----[ OPEN ]------------------------------------------

#

   lang/english.php



#

#-----[ FIND ]------------------------------------------

#

$log_date_fmt = '%B %d, %Y at %I:%M %p'; //cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

// s garibaldi

$other_formats_button="Add Formats";

// e garibaldi



#

#-----[ FIND ]------------------------------------------

#

  'forb_ext' => 'Forbidden file extension.',//cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

  'other_formats_button' => $other_formats_button,   // garibaldi



#

#-----[ FIND ]------------------------------------------

#

  'regenerate_dictionary' => 'Regenerate Dictionary', //cpg1.4



#

#-----[ AFTER, ADD ]------------------------------------

#

  'other_formats_button' => $other_formats_button,   // garibaldi



#

#-----[ NOTE ]------------------------------------------

#

   These same language modifications can be applied to other languages as well.

   Just replace the english text with your native language



#

#-----[ OPEN ]------------------------------------------

#

   formats_upload.php



#

#-----[ FIND ]------------------------------------------

#

   var upload_url = "http://mycpgroot.com/formats_upload/";



#

#-----[ EDIT ]------------------------------------------

#

   Change the URL to point to the formats_upload folder inside your Coppermine Root



#

#-----[ OPEN ]------------------------------------------

#

   formats_helper.php



#

#-----[ FIND ]------------------------------------------

#

   $save_path = "/var/htdocs/cpg14x/formats_upload/";



#

#-----[ EDIT ]------------------------------------------

#

   Edit the path to point to your system's path to the formats_upload folder. This

   looks like the above example on linux/unix servers and on Windows might look like

   C:\webserver\cpg14x\formats_upload



#

#-----[ SAVE/CLOSE ALL FILES ]--------------------------

#

# EoM
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Joachim Müller on April 19, 2009, 09:11:41 am
Thanks for your contribution. I have removed reference to the hotlinked images in your initial posting. We're not fond of hotlinking to external resources (and in fact the bbocde tag [ i m g ] has been deliberately disabled here) as per board rules (http://forum.coppermine-gallery.net/index.php/topic,55415.msg270617.html#msg270617). I have merged the hotlinked images into two actual files and attached them to your initial posting on this thread.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on April 19, 2009, 05:30:41 pm
Thank you for fixing that for me
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: zelal on May 29, 2009, 04:50:05 pm
Dear Garibaldi,

Thanks for your great effort.

I added this feature to my site.

But unfortunately, when a user upload a zip file which has the same name of a previously uploaded (say, by another user) file it replaces the previously uploaded file.

For example, a user named John has taken a photo of Alaska Mountain. He made a jpg version and a BMP version. He wanted to give the BMP file (within Zip) beside the JPG file. Accordingly he zipped it and named "mountain.zip" and then uploaded it using your feature.

After some days, another user named Allan also published his similar image (Himalayan or Alaska or etc. mountain) with zip file whose name is same as earlierly uploaded (by John) zip file i.e. mountain.zip.

Since the upload folder is also same (i.e. /formats_upload/) the upload immediately replaces the earlier one i.e. John's file will no longer exist.

Could you please fix this?

Thanks in advance.

Zelal

Dear Muller, I apology in advance if break the forum rule(s) by posting this in this thread. I searched to have the solution, but I could not find. May be, my search was not proper.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on May 31, 2009, 01:03:16 am
Hi Zelal,

Good point, the zip filenames should be unique. I'll make an update and post it soon. Glad to hear that you like the MOD!
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on June 02, 2009, 05:38:00 am
Hi Zelal,

I've made the necessary changes tonight and tested it on my site. The modification now takes your uploaded file, e.g. myFile.zip, and adds a random number before the extension, like myFile1295.zip. This way, even identically selected files are made unique. I've updated the script with these changes in the first post of this thread. You just have to upload the formats_upload.php and formats_helper.php files after editing their settings as appropriate for your site
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: zelal on June 03, 2009, 11:01:35 am
Hi Garibaldi,

Thank you so much for your nice work. I think many people will like it.

Regards.

Zelal
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on June 29, 2009, 10:48:21 am
Shows me the error
Parse error: parse error in C:\wamp\www\include\picmgmt.inc.php on line 42

Im trying this on Wamp, My directory structure is C:\wamp\www\[All Coppermine files]\
Here's what I have done in picmgmt.inc.php

// s garibaldi
   
   // ******************** //
   // *** START CONFIG *** //
   // ******************** //
   $user1_path = "C:\wamp\www\formats_upload\";
   $user1_url = "http://localhost/formats_upload/";
   $extension = "zip";
   // ******************** //
   // **** END CONFIG **** //
   // ******************** //

What is the solution?
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Joachim Müller on June 29, 2009, 11:12:08 am
If you get a parse error you simply haven't followed the instructions to a T. Undo your edits and re-apply them thoroughly.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on June 29, 2009, 11:50:32 am
I have redone the whole procedur, still getting the same error. Have I inputted the correct values in picmgmt.inc.php
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on June 29, 2009, 05:02:24 pm
It looks like an issue with Windows parsing the slashes as escape characters. Try replacing the double quotes in line 42 with single quotes. This will tell php to treat it completely as a string. If that doesn't work, for each slash "\", replace it with 3 slashes "\\\". I believe that will escape it correctly.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Nibbler on June 29, 2009, 05:07:58 pm
2 slashes.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Joachim Müller on June 29, 2009, 06:21:35 pm
A slash actually looks like this: /
What you're refering to ( \ ) is actually a backslash.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on June 29, 2009, 10:49:07 pm
Sorry, yes 2 backslashes. I was thinking 3 from when I recently had to escape a backslash followed by a quote
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on June 30, 2009, 02:01:57 pm
Thanks guys got it working,  actually used front slashes instead of back slashes in the path.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on June 30, 2009, 05:00:32 pm
Great glad to hear it! It may be the case that although windows uses backslashes for paths, php replaces those with regular slashes for windows paths to avoid this problem of unintentional escape characters
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on July 01, 2009, 07:17:15 am
I added information about this issue to the package attached to the first post and the instructions in the second post
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on July 23, 2009, 04:55:17 pm
I would like to add more extensions i.e rar for supported upload. How can I do that?
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Joachim Müller on July 23, 2009, 05:46:45 pm
How to add other file types (extensions) is beyond the scope of this mod, but has been explained often already. Please use the search. If you can't find good results after performing a thorough search start a thread of your own on the support board, providing the needed details.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on July 23, 2009, 06:12:41 pm
[quote

   // ******************** //

   // *** START CONFIG *** //

   // ******************** //

   $user1_path = "/var/htdocs/cpg14x/formats_upload/";   // NOTE: even if you are using Windows, use forward slashes "/" for paths - e.g. C:/windows/

   $user1_url = "http://mycpgroot.com/formats_upload/";

   $extension = "zip";

   // ******************** //

   // **** END CONFIG **** //

   // ******************** //

   

#-----[ NOTE ]------------------------------------------

#

   Edit the lines the lines after START CONFIG and before END CONFIG,

   adjusting the path of the upload folder for the files. This folder should

   not be inside your Coppermine albums folder. Its permissions may also need

   to be adjusted to 777 to allow upload. You can also adjust the type of files

   that can be uploaded. By default only .zip files are allowed

#

[/quote]

What Im asking about is how to add support for rar in this section?
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Joachim Müller on July 24, 2009, 10:01:01 am
Do as I suggested:
start a thread of your own on the support board, providing the needed details.
Hint: what a needed detail is can be found out by reading the board rules (http://forum.coppermine-gallery.net/index.php/topic,55415.0.html).

Joachim

P.S. You should learn how to quote using bbcode
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on July 24, 2009, 06:31:33 pm
Sorry for my late response. I've created a support topic for this modification in the support forum. Here is a link:
http://forum.coppermine-gallery.net/index.php/topic,60768.0.html

I have posted a response to your question about alternate filetypes there.

Thanks,

Garibaldi
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on July 30, 2009, 09:53:15 pm
I'm releasing an update that includes support for deleting the uploaded file when you delete a picture. To upgrade, simply follow these instructions:
Code: [Select]
#

#-----[ OPEN ]------------------------------------------

#

delete.php



#

#-----[ FIND ]------------------------------------------

#

if (!is_writable($dir)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['directory_ro'], htmlspecialchars($dir)), __FILE__, __LINE__);



#

#-----[ BEFORE, ADD ]-----------------------------------

#

    // start garibaldi
    $g_query = "SELECT user1 FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'";
    $g_result = cpg_db_query($g_query);
    $g_user2 = mysql_fetch_array($g_result);
    foreach($g_user2 as $key => $value) {
if (strpos($value, "http") === false) {
} else {
// if its the url, grab it and cut off the part we don't want and put on the server path
$path = str_replace($CONFIG['ecards_more_pic_target'], "", $value);
}
    }
    if (is_file($path)) {
    unlink($path);
    }
    // end garibaldi

You can download the full installation for this new version in the first post of this topic
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on August 07, 2009, 08:47:24 pm
I tested it on my local server & website but its not working.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on August 07, 2009, 09:43:09 pm
Can you find an image that you want to delete and edit it in Coppermine. Check the value of the Custom User 1 Field and send it back to me. It should be of the form http://yourcpg.com/formats_upload/myzip4895.zip . If that is the case, this script then cuts off the URL making it formats_upload/myzip4895.zip and then removes it. Make sure your upload directory (formats_upload) is 777.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on August 07, 2009, 10:18:20 pm
Here's what my Custom User 1 field contains http://www.wmskins.com/formats_upload/myAlienS2U22195.rar My directory is 777, it is accepting uploads.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on August 07, 2009, 10:41:06 pm
I'll put some debug code together for you and have it up soon for you to test
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on August 11, 2009, 10:39:52 pm
Sorry for the late reply. Replace the code I posted a couple posts up with this in delete.php:
Code: [Select]
    // start garibaldi
    $g_query = "SELECT user1 FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'";
    $g_result = cpg_db_query($g_query);
    $g_user2 = mysql_fetch_array($g_result);
    foreach($g_user2 as $key => $value) {
if (strpos($value, "http") === false) {
} else {
// if its the url, grab it and cut off the part we don't want and put on the server path
$path = str_replace($CONFIG['ecards_more_pic_target'], "", $value);
}
    }
   
    echo "Query: " . $g_query . "<br>Result: " . $g_result . "<br>User 1 Value: " . $g_user2 . "<br>Path: " . $path . "<br>";
   
    if (is_file($path)) {
    echo "Deleting: " . unlink($path);
    }
    // end garibaldi

Then, after you delete a photo on the page where it shows the green or red images for successful or failed deletions, it will print out some information above the table in this format:
Quote
Query: SELECT user1 FROM xxx_pictures WHERE pid='xx'
Result: Resource id #xx
User 1 Value: Array
Path: formats_upload/xxxxxx-23492.zip
Deleting: 1
Please copy and paste it back here and I'll take a look at it.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on August 12, 2009, 01:49:58 pm
Here's what it looks like on my local server.

Quote
Query: SELECT user1 FROM s2u2c_pictures WHERE pid='13'
Result: Resource id #57
User 1 Value: Array
Path: http://localhost/formats_upload/BetterBlogRoll5563.zip
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on August 13, 2009, 04:48:04 am
Ah yes, I see the problem. It appears that the ecards_more_pic_target field in your database is not setup correctly. It should contain the URL of your coppermine site (with trailing slash). If you can correct this in your configuration, you should be able to use the code as is. Otherwise, find:
Code: [Select]
$CONFIG['ecards_more_pic_target']and replace it with (in this case):
Code: [Select]
http://localhost/
After doing this, give it a try again and see if it works
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on August 13, 2009, 10:48:32 am
Thank you got it working
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on August 13, 2009, 04:27:17 pm
Great! Glad to hear that you got it!
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: SpectroPro on September 07, 2009, 09:29:47 am
Something I noticed...and this is working ALMOST perfectly on my site.  But, when you delete a file from the EDIT FILES part of the albums list...the picture will be deleted..but the files are not.  The only way for them to be deleted currently, is by doing the delete from the lone file (picture) screen. 

I hope this makes sense...  If not, I can maybe explain better and show pictures of what I mean.

Can this be fixed so that no matter where you delete the picture from, it deletes the associated file(s)?

- Greg
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on September 07, 2009, 02:07:51 pm
Correct, I would like to add on that,
Also when we edit file properties & upload another file from there, the previous file doesn't gets deleted.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: SpectroPro on September 07, 2009, 06:34:41 pm
Correct, I would like to add on that,
Also when we edit file properties & upload another file from there, the previous file doesn't gets deleted.

I just noticed this as well.  Can't update or change the file associated with the pic by just uploading a new file.  Maybe a new button, 'Update File'??  This would simply delete the old and put in the new.

Also, curious as to why when you upload, the window wording shows File Queue....???  I can select multiple files, but it will only ever allow one file to upload at a time.  Then you select another.  Thus, no queue.   Just curious about this...am I missing a way to upload 2 or more files at once for a pic?

I am actually wanting, for my use of this....to have more than one pic per file more than one file per pic.  But I am very happy to have this as it is currently, because it will allow me to open my site (graphic object site...for 3d objects for use in games, sims, movies, etc...)  I can imagine it will only get better and more feature enhanced in the future.. 

Thank you very much for this add-on (mod)!!!!!!

- Greg
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on September 07, 2009, 09:26:40 pm
I am trying to tweak a function that adds a random number at the end of filename. I tried to change it that it only adds the random number when a file already exists with the same name.

This is what I have tried but it doesn't work. Also the popup windows remains open when clicked Done & loads the main page.
Code: [Select]
function finish() {
var upload_url = "http://localhost/formats_upload/";
var filename = str_replace(" ", "%20", document.getElementById("fileNAME").value);

if (file_exists(upload_url + filename)) {
window.opener.document.getElementById(window.name).value = upload_url + substr(filename, 0, strlen(filename)-4) + document.getElementById("rand").value + substr(filename, strlen(filename)-4);
} else {
window.opener.document.getElementById(window.name).value = upload_url + substr(filename, 0, strlen(filename)-4) + substr(filename, strlen(filename)-4);
}
close();
}

How can i get it to work?
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on September 08, 2009, 04:46:28 am
What does this random number addition do that is different from how the modification already adds a random number to the end of the file string?
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on September 08, 2009, 05:36:26 am
NO, NO you are getting it wrong.
I want that a random number is only added when a file exists with the same name, else the file name remains the same as uploaded.
But I can't seem to figure it out with my code.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on September 15, 2009, 05:09:47 am
Try finding this code in formats_helper.php:
Code: [Select]
// Make it unique
$file_name = substr($file_name, 0, strlen($file_name)-4) . $_GET['rand'] . substr($file_name, strlen($file_name)-4);

Replace it with this:
Code: [Select]
// test if it already exists
if (exists($file_name)) {
// Make it unique
$file_name = substr($file_name, 0, strlen($file_name)-4) . $_GET['rand'] . substr($file_name, strlen($file_name)-4);
}
See if that works.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: mushipkw on September 16, 2009, 08:09:23 am
No, its not working.
After clicking Done in the popup windows. The textbox shows filename with random numbers & the fike doesn't gets saved on the server.
Title: Re: Formats Upload Modification - Associate a File with each Image
Post by: Garibaldi on September 16, 2009, 08:30:21 am
In that case I'm not sure how to implement what you want. I guess you'll just have to use it with random numbers after all uploads (or none at all). The problem is that the random number is created in Javascript which is on the client side. It is tricky to have that type of communication between the client and server