Gossamer Forum
Home : Products : DBMan : Customization :

Image upload panacea

Quote Reply
Image upload panacea
Well, I've been trying to implement JPDeni's file upload mod.I have been getting 500 server error, but when I run from the command line I get no error in the script provided, file-upload.cgi
I tried the unmodified version and it worked, so I started trying to figure what was wrong. I tried to get the parameters in with a library called cgi-lib.pl using $in{'variable'} but that seems to screw up the file upload data.
Well, what I'm trying to say is that the command that is being rejected by the server when I run the script is

$db_setup = param('db');

that should bring up something that was submitted from the form, that is sent with a post method.
How could I get input from a form using another procedure, but through the post method?
I think that if I could read the variables from the form
<FORM ENCTYPE="multipart/form-data" ACTION="$db_dir_url/file-upload.cgi" METHOD="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="newfilename" value="$rec{$db_key}">
<TABLE BORDER=0 WIDTH="460">
<TR><TD ALIGN=RIGHT>File:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-01" SIZE="35"></TD></TR>
<TR><TD><INPUT TYPE="SUBMIT" VALUE="Upload File!"></TD>
<TD ALIGN=RIGHT><INPUT TYPE="RESET" VALUE="Reset Form"></TD></TR>
</TABLE>
</FORM>

the problem would be solved.
Thanks for the help!
Quote Reply
Re: Image upload panacea In reply to
I'm sorry that I haven't gotten back to you. I have been trying to figure out why it works just fine for some folks and not at all for other folks. (Which is also why I haven't send info to some of the other people who have asked for it.)

When I can figure out what is wrong and why it doesn't work, I will let you know.


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
I was wondering how you did the image upload? I just got done with the same mod but Im not that happy with it, very clunky.

Feel free to check it out and make some test posts at http://www.hotrodding.net/...s/db.cgi?uid=default

------------------
JRM Studios http://www.jrmstudios.com
The Hotrodding Network http://www.hotrodding.net

Quote Reply
Re: Image upload panacea In reply to
Yes, it is clunky. It does work for some people, though.

I probably should have waited to even think about it until I was more familiar with the CGI.pm module. Sometimes I'm not sure what I should do. Should I go ahead and make something ugly that might work or wait until I know enough so that I can make something pretty? In the meantime, what do I tell the folks who are clamoring for a mod?

I welcome -- encourage! -- anyone else to create mods. Please let us know when you've done something and I'll be eternally grateful.


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
Oops! I think you misunderstood me. Smile
I was calling my file upload mod clunky! I was just wondering what you did, I had all sorts of probs integrating it into DBman.

What I did in the end was make a hidden field in the add form with $db_key.jpg in the image field, and a Yes/No check box for Photo. Then if the user selects Yes for photo they will see a image upload form on the add success page. I used Filemans ability to rename a file in another hidden field with the value of $db_key.jpg. I just replaced all the HTML in fileman with a file uploaded page and a link back to the default user display.

I hope you can understand that! I think I got sunstroke today Smile

------------------
JRM Studios http://www.jrmstudios.com
The Hotrodding Network http://www.hotrodding.net

Quote Reply
Re: Image upload panacea In reply to
My apologies. I thought you were one of the folks who had written to me for the mod. I'm sending out warnings with the mod that it works for some and not for others.

I'll send you the info for my mod by email. (I kinda want to keep track of it right now, since it's a bit hinky.) If you can merge the two, that would be wonderful!

The basis for my upload mod is a script I found at CGI Resources.

Anyway, I'll send you the info on how to do it. Maybe you can help the folks that it doesn't work well for.

Stay out of the sun! Smile



------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
Hi,

I have the image upload MOD working just great. In fact I have added the extra mod which lets me upload thumbnail, and large size images at the same time, (thanks JPDeni).

For a while I got the same Interal Server 500 Error message, but I got it to work in the end. The only problem is, I don't remember what I did. I'm going to try to figure it out. As soon as I find out, I'm going to let you know.

Thank You
Quote Reply
Re: Image upload panacea In reply to
I just got it to work.

The 500 server error was caused by the the following lines in file_upload.cgi. It could not
find any of the subroutines.

Code:
&auth_cleanup unless ($auth_no_authentication); # Remove old session files.

($status, $uid, $per_view, $per_add, $per_del, $per_mod, $per_admin)
= &auth_check_password;

If you want only those with admin permission to be able to upload files,
set the following to
unless ($per_admin) { &html_unauth; exit; }

#unless ($per_add) { &html_unauth; exit; }

After I commented them out I started getting errors on how the upload directory was not
there or not chmoded to 777.

I fixed that by adding
$SAVE_DIRECTORY = "/home/www/jrmstudios/class2_pics";

into file_upload.cgi I have no idea why it was not reading it from default.cfg???

I must say I like it ALOT better than my upload mod. (the pics get deleted when the
record is deleted .. YAY!!)

The only thing I will be changing is not showing the file upload form if the user did not
select yes on the add form.

------------------
JRM Studios http://www.jrmstudios.com
The Hotrodding Network http://www.hotrodding.net

Quote Reply
Re: Image upload panacea In reply to
I'm glad it worked for you. I don't know why it doesn't read from the .cfg file either, or the auth routines. One way I fixed that (because I didn't want someone to be able to just upload a file without being logged in) was to copy the auth_check_password subroutine from auth.pl to the file-upload script. (I didn't worry about the auth_cleanup subroutine.)

It's still a clunky way to do it. I've learned more about Perl since I wrote that and I'll try to make it a little less clunky later.

Still don't know why tachus is having a problem, though.


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
Mr Marshall, my man!
Well, happy to close up this thread. The image panacea is no more a panacea, at least for me. Tried cutting out thye auth piece of code and eureka, got the same reply you got. The script ignored the variables set in my .cfg file. So ... just put them in the file-upload script and got everything to work.

Thanks Mr Marshall

and thanks JPDeni. Without your spark nothing would be possible. Looking forward to seeing a script of your creation released soon.


[This message has been edited by tachus (edited June 01, 1999).]
Quote Reply
Re: Image upload panacea In reply to
Cool!

I guess that tells me what I have to do. I'll make the changes when I can and have the mod up on my site.

Thanks to everyone who has beta-tested this for me.


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
I've attempted to use the upload cgi and am having success loading small file <6kb ... unfortunately, whenever a get a decent size file, the thing times out. Any ideas?
Quote Reply
Re: Image upload panacea In reply to
Glad I could help. Smile

------------------
JRM Studios http://www.jrmstudios.com
The Hotrodding Network http://www.hotrodding.net

Quote Reply
Re: Image upload panacea In reply to
Well, I made changes to the file-upload mod that I thought would make it work for everyone. I uploaded it to my site and got a 500 error. The previous mod works for me and there doesn't seem to be a way for me to test the new one. This may end up to be something that each person is going to have to create for himself.

------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
Hey Carol,

I have script that may help debugging. It gives you the output of a script like telnet w/ all the environmental stuff.

It helps a lot when your using post, just change the form action to
http://someplace.com/cgi-bin/debug.pl/script_ to_debug.cgi

I have a copy at my site
www.jrmstudios.com/debug.pl.txt

Note: I did not write it Smile

------------------
JRM Studios www.jrmstudios.com
The Hotrodding Network www.hotrodding.net



[This message has been edited by John R Marshall (edited June 02, 1999).]
Quote Reply
Re: Image upload panacea In reply to
I have no idea why it would time out, imart, unless your server or your connection is slow. I've never run into the problem.

I have decided that I am out of the file upload mod business. I am sorry, but I just don't know enough to be able to answer the questions of folks that it doesn't work for. I'm not sure I should even give out the one that I know works for some people, but not for others.

------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
Well, maybe you guys think that I only bring problems around over here.
This time I'd like to change that. I have found another way to debug problems. Maybe you people already know it. But as Mr. Marshall has brought up that debug script, I think that there's something a little smarter that can be done. That is, add the following line under the "use cgi" line:

use CGI::Carp (fatalsToBrowser);

gosh, had I known this before, I would have solved the problem very fast. This line, in some sense, sends you the message recorded onto the server log to your browser. I have no server error log. And for the ppl that have it, I guess this will make your debugging a little quicker.

Hope I have added my 2 cents. JPDeni, you should provide your script to ppl that ask it, I'm sure that after inserting that line everybody will find the mistake easily

One thing that I have thought is that it is really important to have perl 5.004 in order to get things working right. The script didn't work for me until I selected the 5.004 perl (before I was pointing onto 5.003)
Well. Thanks for the script again, keep doing good! Smile
Quote Reply
Re: Image upload panacea In reply to
That's a good idea and I'll probably do it. However, figuring out where the problem is gives me only half of the solution. The other half requires me to figure out how to fix the problem. I just don't have the knowledge or experience to know why the error message comes up.

I'll see what I can do.


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
And now for the continuing saga of JP's upload mod. Smile

I tried my modified mod again and found out I'd made a really dumb error which caused it not to work. (Actually, not dumb. Just a "newbie" type error. I forgot to change the path to Perl.) It now works without having to pull in anything from any other file. Every variable the upload script requires is passed by the form, so there won't be any problems with missing subroutines and such.

I've sent off the mod to three more people tonight, so I'll see what happens. The new one works on my server (but then, the old one did, too).


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
I would like to receive and test a copy of your upload mod as well. Please email to pwatkins@retaillabs.com

Thanks
Quote Reply
Re: Image upload panacea In reply to
Upload mod works like a charm for me! Thanks a million.

Mike
Quote Reply
Re: Image upload panacea In reply to
I also would like your upload mod. Thanks a bunch!
Quote Reply
Re: Image upload panacea In reply to
You can pick up the files at my site.

You'll need two files from my site
http://www.jpdeni.com/dbman/file-upload.txt
http://www.jpdeni.com/dbman/file-upload_cgi.txt

So far, the newest version seems to be working for everyone. (Knocking wood!)


------------------
JPD





Quote Reply
Re: Image upload panacea In reply to
I've noticed a little quirk in the upload. I modified the script so if it doesn't find a .gif or .jpg, it displays a "default" image. I mention this on the side - I don't think it actually relates to the problem. The problem is after I upload the file, it doesn't actually display on the page until after I back out of dbman alltogether. When I go back in and view the record, it displays fine. I suspect it may be a caching issue, or something along those lines. I'd be interested in your thoughts.
Quote Reply
Re: Image upload panacea In reply to
I have no idea. Right now I can't get it to work on my server at all. I think there's something going on with the server, though.



------------------
JPD