Gossamer Forum
Quote Reply
add FILE type
I'm having a problem using the add or modify methods with file types.

I have something like this:

Code:

my $args = $IN->get_hash; $db->modify({Username => 'Jonathan', Image => $args->{Image}})

If I want to modify any other field besides a file type, everything works great.

However, when I browse for a file, it updates to the DB to say the actual filename, but it does not create or modify the file at all.

I believe that I was able to track down the problem to this statement in GT::SQL::Tables around line 325

Code:

( not ref $fh and not $set->{$col."_del"} ) and ( $self->error( 'FILE_NOGLOBREF', 'WARN', $col ), next );

The code seems to be using the next option and forgetting to create the file. Do I need to reference the file handle differently? What am I doing wrong?

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] add FILE type In reply to
Hi,

Mmm... not sure what you are trying to do though?

Code:
my $args = $IN->get_hash;
$db->modify({Username => 'Jonathan', Image => $args->{Image}})

...would only update the record to the filename you are passing. To actually upload the file, you need to use something like this:

Code:
my $args = $IN->get_hash;
$db->modify({Username => 'Jonathan', Image => $IN->param('Image') });

...and then GT::File / GT::SQL should take the fact it is a file into consideration, and update the file entry in pre_Links_Files.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] add FILE type In reply to
Well I'm just creating a simple script to upload a file and change information.

It's still not uploading the file.

I even tried:

Code:
$db->modify($IN->get_hash);

I'm not sure what this line means in GT::SQL::File.pm (line 323)

Code:

( not ref $fh and not $set->{$col."_del"} ) and ( $self->error( 'FILE_NOGLOBREF', 'WARN', $col ), next );

But I did manage to track down the problem to that line. If I add a test print statement before that line, it prints, after that line not so much.

It seems like I'm missing something so simple. But I don't understand what.

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] add FILE type In reply to
Hi Jonathan,

It seems that your table is reated manually and it does not have a associated File table which is used to stored file' information. You can use the Table Editor in admin as below

http://URLtoadmin/admin.cgi?db=TABLE&do=editor_table_form

At that page, you can modify the file column and the table editor will create the file table for you.

Hope that helps

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] add FILE type In reply to
No, the file table has already been created. It seems that if I browse for an image through the Table Editor everything works fine. The image uploads and updates correctly.

However, when I use MY script that simply takes the input and adds it to the table like so:

Code:


$db->modify($IN->get_hash) or die "Can't Modify: $GT::SQL::error";

.... it does not upload the image, it just changes the regular table to say the name of the file, and does not modify the FILE table at all. All of the other fields update fine.

I keep thinking that if I change the input method it will work. Is there something that the Table Editor says that a basic table modify command doesn't?

It does not make sense to me.

- Jonathan
Quote Reply
Re: [jdgamble] add FILE type In reply to
I see. So that the error says?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] add FILE type In reply to
Thats the thing. It doesn't give an error. It modifies or adds a new record as if everything works. And everything does work perfect, except the FILE column.

- Jonathan
Quote Reply
Re: [jdgamble] add FILE type In reply to
Please ensure that your form have this
<form method="POST" enctype="multipart/form-data"

Hope that helps!

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] add FILE type In reply to
LOL That did it! I knew it was something so simple that I was missing.

Thanks a bunch!

- Jonathan