Gossamer Forum
Home : Products : Links 2.0 : Customization :

NEW - Upload Mod

(Page 2 of 3)
> > > >
Quote Reply
Re: [shiner] NEW - Upload Mod In reply to
Can you add a test category to make sure that isnt the problem.
Quote Reply
Re: [RedRum] NEW - Upload Mod In reply to
Paul,
There is a category called Pictures already in place, but I added a category called test if that is what you need.

http://www.carsonscorner.com/pages/index.html

Thanks,

Chris
Quote Reply
Re: [shiner] NEW - Upload Mod In reply to
When I go to the add page I get:

Category: error building select field: no select fields specified in config for field 'Category'
Quote Reply
Re: [RedRum] NEW - Upload Mod In reply to
The way that page is written (pages/index.html), it is looking to grab the current category - there is no "if statement" that would void that out. If you go to one of the category pages like:

http://www.carsonscorner.com/pages/Pictures/

You can try to add a resource and get the

"Unknown tag: Title" error.

If you know how I can change the password on fileman - I can give you access to that if it would help.

Thanks,

Chris
Quote Reply
Re: [RedRum] NEW - Upload Mod In reply to
Its a greats Mod, just what i been looking for. One slight problem though.

This only works for the users add.cgi and modify forms. How do I add the propper field to the administrators add/modify forms.

Im sure is something as simple as adding the new row and form extension to the forms but where in the script are these forms kept.

Also is there a way so that the file gets renamed to what ever the link ID is such as 1.gif or 3.gif etc...
Quote Reply
Re: [Ibis Fernandez] NEW - Upload Mod In reply to
Changing the admin page isn't easy. It requires lots of changes to db.pl

It would be better to just name the file manually and upload it using ftp to your images directory and just enter the file name in the admin form.

As for the second question, you can't really name by id as if someone uploads more than one images it will mess up.
Quote Reply
Re: [Paul] NEW - Upload Mod In reply to
Could someone point me to where this mod is available? I couldn't find it at http://www.wiredon.net/gossamer/mods.shtml

Thanks
Quote Reply
Re: [jelevin] NEW - Upload Mod In reply to
They are back now :)
Post deleted by jelevin In reply to
Quote Reply
Re: [Paul] NEW - Upload Mod In reply to
excuse me. i saw some one ask the question before, but can you tell me how to name the file name [eg: xx. jpg] as the $ID name?



beause we can add one more field at add.html , something like a drop down meun.

[logo]

[cover]

[default]

then it will able to rename it as..

$ID+logo.jpg or $ID+cover.jpg ... etc



I am looking forward your reply .. Thx
Quote Reply
Re: [speedmax] NEW - Upload Mod In reply to
Problems!

I'm getting the following error when using Add.cgi with the script installed:

CGI ERROR
==========================================
Error Message : Can't open /103046876620028215096163765775228.jpg : Permission denied
Script Location : add.cgi
Perl Version : 5.006001


I've set the directory to 777 and the images upload directory to 777 too. Am I missing something?

my Links.def has:

FilePic1 => [32, 'alpha', 1, 50, 0, '', '^[^\.]+\.(gif|GIF|jpg|JPG)$'],
FilePic2 => [33, 'alpha', 1, 50, 0, '', '^[^\.]+\.(gif|GIF|jpg|JPG)$'],
FilePic3 => [34, 'alpha', 1, 50, 0, '', '^[^\.]+\.(gif|GIF|jpg|JPG)$'],
FilePic4 => [35, 'alpha', 1, 50, 0, '', '^[^\.]+\.(gif|GIF|jpg|JPG)$'],

And I've set $db_file = 32; in the important fields section
Quote Reply
Re: [boom] NEW - Upload Mod In reply to
Fixed this problem - but still getting a Invalid Format error if the user decides not to enter any images when adding a record.
Quote Reply
Re: [boom] NEW - Upload Mod In reply to
Try changing the regex to:

^(?:|[^\.]+\.(?:gif|GIF|jpg|JPG))$

Last edited by:

Paul: Aug 28, 2002, 8:37 AM
Quote Reply
Re: [Paul] NEW - Upload Mod In reply to
File1 => [32, 'alpha', 1, 50, 0, '', '^(?:|[^\.]+\.(?:gif|GIF|jpg|JPG))$'],
File2 => [33, 'alpha', 1, 50, 0, '', '^(?:|[^\.]+\.(?:gif|GIF|jpg|JPG))$'],
File3 => [34, 'alpha', 1, 50, 0, '', '^(?:|[^\.]+\.(?:gif|GIF|jpg|JPG))$'],
File4 => [35, 'alpha', 1, 50, 0, '', '^(?:|[^\.]+\.(?:gif|GIF|jpg|JPG))$'],

Thanks for replying Paul. I tried that (as above) but the error
  • File1 (Invalid format)
  • File2 (Invalid format)
  • File3 (Invalid format)
  • File4 (Invalid format)

    Is still coming up when the user doesn't put upload any images....

  • Last edited by:

    boom: Aug 28, 2002, 4:42 PM
    Quote Reply
    Re: [boom] NEW - Upload Mod In reply to
    Hmmm that should have worked, oh well, how about:

    ^\s*|[^\.]+\.(?:gif|GIF|jpg|JPG)$
    Quote Reply
    Re: [Paul] NEW - Upload Mod In reply to
    That works! Thank you... I will keep on testing it to see if it's cool, but so far it's doing it right now!
    Quote Reply
    Re: [seeker] NEW - Upload Mod In reply to
    I believe that I've come up with a solution to the problem seeker has here. The core of the problem is that the standard html upload field object absolutely CANNOT accept a default value. So if you do the following:

    <input name="File3" type="FILE" id="File3" value="image.jpg">

    image.jpg will not upload when you submit the form. This means you cannot populate the form with the previosly uploaded resource as follows:

    <input name="File3" type="FILE" id="File3" value="<%File3%>">

    When you view the source of the form you will see the value of <%File3%> in the form element but it will be removed upon submission of the form.

    Similarly it is IMPOSSIBLE to populate the form by cutting and pasting or any sort of Javascript.

    So there's the problem. If you want the user to be able to preserve the previosly uploaded photo upon modification you must ask him/her to upload it again. This is a pretty clunky UI to say the least.

    I have have 5 file upload fields like seeker and Iím using Paulís upload mod as well as his password modify mod. Iím pretty sure the things I did will work with upload mod alone.


    So basically the way to fix it is to have a hidden form field that passes back and forth the name of any previously uploaded file. By using this, as well as being able to test
    if the form field has a new upload in it we can keep the old file, delete the old file and or add the new file.

    Here what you need to do:

    For each upload field of your modify (modify.html Ė Iím using templates) page put in a hidden that contains the value of File(x) as follows:

    # first, if the user has previously uploaded an image, show it to them:

    <%if File1%>
    <img src="<%upload_url%>/<%File1%>"><br><br>
    <%endif%>
    # hereís the upload form field
    <input name="File1" type="FILE" value="">
    # Hereís the hidden field that holds the file name of the previously uploaded file.
    # Note: If no file has previously been uploaded the value field will be empty.
    <input type="hidden" name="File1Transfer" value="<%File1%>">

    # Do this for each file upload making sure
    # that File(x) and File(x)Transfer have the same number for x.

    # Next, in modify.cgi replace Paulís sub parse_me_and_upload with the following.
    # Be sure to back up the original sub parse_me_and_upload in
    # case this one doesnít work.

    sub parse_me_and_upload {

    use CGI qw(:standard);

    my (%in);
    my ($fnum,$file_field,$file_name,$ext,$bytes_count,$size,$buff);
    my ($num)=1;
    my ($IN) = new CGI;

    # create a hash for all input - name => value
    for ($IN->param) { $in{$_} = $IN->param($_) }

    # loop through the input
    for (keys %in) {

    # if the field name matches File(DIGIT) this is a file upload field...
    if (/^(File\d*)$/i) {

    # establish and number associative files in array
    # $in{$file_field} = name of file being uploaded from form.
    # $1 = Form element name ie. File1

    # Increment the form element counter
    $fnum = $num++;
    # do some stuff that I've yet to understand.
    $file_field = $1;
    $in{$file_field} =~ /([^\/\\]+)$/ and $file_name = $1;


    # If the File(X) field is empty

    if (length($in{$file_field}) < 1 ) {

    # just to copy the value of File(X)Transfer
    # into $in{$file_field}. This will either be an empty string or
    # the previously uploaded filename.

    $in{$file_field} = "$in{'File' . $fnum . 'Transfer'}";

    # Other wise the File(x) form upload element has something in it.

    }else{

    # So first remove any previously uploaded files in that file(x) position
    if (length($in{'File' . $fnum . 'Transfer'}) > 1) {
    unlink "$upload_path/$in{'File' . $fnum . 'Transfer'}";
    }

    # Now let's go ahead and upload that new file

    $rand = sprintf "%05d", rand 1_000_000;
    $file_name = $rand . $file_name; # Prevent files being overwritten by giving them a random prefix

    open U, ">$upload_path/$file_name" or &cgierr("Can't open $upload_path/$file_name : $!");
    binmode U; # needed for Windows servers

    while ($bytes_count = read($in{$file_field},$buff,2096)) {
    $size += $bytes_count;
    print U $buff;
    }
    close U;
    $in{$file_field} = $file_name;

    # create an array of upload fields so we can unlink if there's a booboo
    push @uploads, $in{$file_field}
    }
    }
    }
    # return the %in hash as normal
    return %in

    }


    # Also, in sub process_form change the following

    # First make sure the link isn't already in there.
    open (MOD, "<$db_modified_name") or &cgierr ("error opening modified database: $db_modified_name. Reason: $!");
    while (<MOD>) {
    chomp;
    @values = split /\|/;
    if ($values[0] eq $in{$db_key}) {
    close MOD;
    &site_html_modify_failure("A request to modify this record has already been received. Please try again later.");

    # remove any new uploads.
    unlink "$upload_path/$_" foreach @uploads; # <--- New Line Here...

    return;
    }
    }
    close MOD;



    Well, I think that's it. This all worked for me. Hopefully it works for you too.

    ps. if anyone can tell me how to limit the size of a file upload that would be fantastic!

    Last edited by:

    Swaylock: Oct 8, 2002, 4:28 PM
    Quote Reply
    Re: [shiner] NEW - Upload Mod In reply to
    I am having the same problem

    http://www.drpic.com/links/

    Unkown Tag: Title

    or when modifying:

    Unkown Tag: Current URL
    Quote Reply
    Re: [Paul] NEW - Upload Mod In reply to
    Unkown Tag: upload_path



    The title is working now, I added 4 fields for 4 images

    I added 4 delimiters via your update.cgi file

    any ideas?

    http://www.drpic.com/links
    Quote Reply
    Re: [jebridge] NEW - Upload Mod In reply to
    I found my problem.

    it was in the html:

    I had set the url to <%upload_path%>

    which is the absolute path.

    i replaced this with www.mysites.com/upload/path/<%File%>

    works fine now.

    Great Mod! Thanks!
    Quote Reply
    Re: [jebridge] NEW - Upload Mod In reply to
    Quote:
    ps. if anyone can tell me how to limit the size of a file upload that would be fantastic!
    Did anyone figure this out?

    thanks
    Quote Reply
    Re: [Paul] NEW - Upload Mod In reply to
    Paul,

    I am trying this mod. All works well and I have changed the regex per your last post. However, there is one problem - when the user does not upload any file, it still writes numbers like "1032039745" in the upload directory. Since I am linking to the image directly in the detailed page, if nothing is loaded a broken link shows up because of those numbers.

    Any idea how to fix this problem?

    Also:

    1. Is there a way to limit the size of the upload?
    2. Is there a way to delete the image(s) from the upload when admin deletes a correponding link?

    Other than those minor issues, this is a nice mod.

    thanks

    Also, thanks to swaylock - your idea is working well.

    Last edited by:

    socrates: Nov 23, 2002, 4:27 PM
    Quote Reply
    Re: [socrates] NEW - Upload Mod In reply to
    Quote:
    when the user does not upload any file, it still writes numbers like "1032039745" in the upload directory.

    Is anyone else having this problem and is there a solution?

    thanks
    Quote Reply
    Re: [Paul] NEW - Upload Mod In reply to
    Hi Paul

    Is this mod still available? I tried to use the link above, but I got an error stating that wiredon could not be found Frown

    Many thanks Smile

    ------------------------------------------
    Quote Reply
    Re: [Paul] NEW - Upload Mod In reply to
    Hi Paul,

    Firstly, thanks for making your upload mod available, which I am personally interested in using. Unfortunately, it appears as if the link isn't working: http://www.wiredon.net/gt/download.shtml , please can you confirm this.


    Thanks
    Hamsterpants
    > > > >