Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Image Library

Quote Reply
Image Library
I recently purchased Links SQL after reading that it can be used as an image library. However, after spending some time with it I'm unsure as to how one might provide the image upload feature. I can create the necessary addional columns, but the big problem is getting the image from the client to the server - is there a script to do that which I'm missing? I'm not a Perl guru, although am comfortable in Cold Fusion where a file upload can be achieved in a few lines. Does anyone have an idea how one might go about creating an image directory.
Quote Reply
Re: [thewombat] Image Library In reply to
Hi,

It might be as simple as changing your upload script to include an <input type=file ..> field, and adding the 'multipart' modifier to the <FORM> tag.

This uploads the file to your default files area, in the format you specify in the set up of the column hash/no-hash.

I have several routines that upload, check, and do other things to files, but have been steam rolled by life lately in polishing them up and releasing them. I've been considering releasing them as open mods, but am still deciding on how to do that. Part of what I needed in my system was to be able to specify an upload area (besides the default, or let the system pick defaults based on the file, so you can spread your file system over several devices if necessary).

As I said, the programs are in the state they were in in mid June, with only a small start to incorporate the file_type field, and I'm trying to decide if I should just release them to allow group input, or to keep them commercial and try to pick up the development again.





PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Image Library In reply to
I can do the form no probs, but I need to post it to a script which will do the upload - this is what I'm currently missing at the moment? A script which checks the attributes of the file (size, GIF/JPEG, etc) and puts the file in the right drive location based on category. Then updates the database information with this file location as well as other attributes posted by the user.
Quote Reply
Re: [thewombat] Image Library In reply to
Hi,

The steps you need are:

1. Add an image column to your links database. Goto Database->Links->Properties->Add Column. Then set type = CHAR, and form type = FILE.
2. Try out the admin and you should be able to upload files and have them stored on the server.
3. Now, to get the user side working, you want to edit the include_form.html (or whatever you are using for the add form) and make sure ENCTYPE="multipart/form-data" is in your <FORM> tag, and that you add <INPUT TYPE="FILE" NAME="ColumnName"> to it somewhere.

Now users will be able to upload images/files that you can approve/validate.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image Library In reply to
Hi Alex,

Thanks for that - now understood, and beginning to work. I've added a Regex code that I found in another thread to ensure that it only allow GIF/JPG/PNG files so no .exe can be uploaded.

However, I have a problem in that when trying to view the image, it tries to download the image (or possibly script) rather than display it. Eg - click on "View" from the administrator and it downloads.

How do I fix this? I saw a thread last night which mentioned fixing something in GT/SQL/Admin/file_sub-view or something like that, but that file didn't exist - could you clarify the location of the file and the line number which requires changing?

Gradually getting there!!

Many thanks,

Ross
Quote Reply
Re: [thewombat] Image Library In reply to
Hi,

It's most likely a content type issue (i.e. the browser did not tell the script it was an image). We will improve this in the next release. The file mentioned is admin/GT/SQL/Admin.pm

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image Library In reply to
Hokay, thankyou. Have that file - what line number should I change, and what to?

Ross
Quote Reply
Re: [thewombat] Image Library In reply to
This is where a "hook" comes in :) You would do something like that in a pre-add hook.

Problem: If the file failes, you want to go back to an upload/verify screen to give the uploader another chance. If you add the file, they will not know the upload failed.

Can't do this in a post hook for the above reasons.

There are not enough "hooks" in links to do this properly.

I wrote an external program (or two) that handled the uploads of images/files. I tried several ways of doing it, but given how links works the best way I found was:

1) upload the link.
2) Allow a user to add/modify/update the link -- even in the preview area -- for the sake of adding attachments. "Special casing" this event is more complicated than using the _same_ routines you'd use for the user modifying existing/validated links.
3) It requires a "validated" flag in the attachment record.

It's even more complicated than this, but the key to the above logic, rather than the "all in one" logic, is that you have a LinkID _BEFORE_ you try to upload files so that you have the ability to figure out your place and return to it (ie: redisplay the Link by it's LinkID) if you need to allow another try.

It gets way too complicated, for little benefit, to allow "all in one" add link + upload file from the same screen. With the new proliferation of browser bugs as well, it's better to capture the data in steps, rather than all at once.



PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.