Click to See Complete Forum and Search --> : cgi access to delete files???


mychl
06-13-2002, 10:42 PM
What I did was made a script to generate thumbs and an index.html in a directory of JPG's. I also have a script that lets users upload images via http to an upload directory on my server.

What I'm trying to do is call a script (perl) that will delete all thumb*.jpg files as well as *.html images gefore re-running the script to generate the thumbs etc...

I'm doing this to try and make it easy for people who upload an image, to view it immediately in a thumbnailed table.

I'm also having difficulties getting my delete and regenerate script to redirect? to an html file once the cgi is done.

Anyone got any tips or suggestions for me? In my apache error log, I see that permission is denied on the image files I'm trying to unlink... well, here's my script if anyone wants to see it....

script (http://mychl717.com/linked/refreshupload)

dchidelf
06-14-2002, 12:20 AM
Location is an http header.

The http headers need to be written before any html and followed by \n\n

After the \n\n the remaining data is treated as html text. Apache used to return an Internal Server Error when a cgi script did not print headers before html body, but it seems now that you can get away without code like:
print "Content-type: text/html\n\n";
But to use Location you would still need to use:
print "Location: $redirect\n\n";
before any other output.

So to redirect using Location you couldn't have any output written first. Otherwise "Location: $redirect" is treated as text.

You could define a javascript function to perform the redirect and call it after you are done printing messages.

[ 14 June 2002: Message edited by: dchidelf ]