PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that I am trying to build a Web GUI front end to interface with the script.


Essentially the script takes a CSV file as input processes it and spits out several new files based on the lines frm the CSV.

My initial approach was to upload the file and then process it. This is where I am stuck. When I go to upload the file the script creates an empty file with the correct name. I used the tutorial here:

http://www.perlfect.com/articles/upload.shtml

and this one here just returns a 500 error

http://articles.sitepoint.com/article/uploading-files-cgi-perl

This leads me to my first question, is it better to upload the file then process it, or is it possible to open it on the client computer and process it server side? Since I am going to delete the CSV from the server at the end of the script anyway does it actually make sense to upload it, processit, then delete it?

Finally, I am able to get the file uploaded using php, is there a way to redirect to my perl script? The problem I run into here is I don't have a way to pass the newly uploaded filename to the script.

Any thoughts/suggestions/hints are greatly appreciated.

Replies are listed 'Best First'.
Re: Local File vs Uploaded File
by marto (Cardinal) on Oct 18, 2010 at 14:33 UTC

    May I suggest working through Ovid's CGI Course - Resurrected and Updated!. Famliarise yourself with the concepts here regarding debuging and security. Read some of the comments on the perlfect article regarding security. It can be dangerous to simply copy code from the web and run it on your (or someone elses) system.

Re: Local File vs Uploaded File
by locked_user sundialsvc4 (Abbot) on Oct 18, 2010 at 14:22 UTC

    I think that you will need to discover why the 500 Error message is occurring.   Check the server logs.   You have an error in your code somewhere.   (Please don’t post it...)

    At the risk of sounding trite, first be sure that your Perl program is running properly at all.   There are many environment settings that must be “just so” in order to run a Perl CGI-script, say in Apache.   When rolling out stuff like this, I am careful not to be content with, “well, it seems to be working...”   Instead, I force myself to think, “prove to me that it is working.”   My skepticism is usually rewarded.

Re: Local File vs Uploaded File
by PyrexKidd (Monk) on Oct 18, 2010 at 15:47 UTC
    Sweet. That looks like it will be helpful in configuring my Apache server.
    Can someone please answer my original question about uploading a file vs opening it on the client computer?
    is it possible?
    Which is more efficient to upload, open, process, delete, or open, process, garbage collect.
    fortunately this is not a production server; I am still learning, and relatively new to web page programming. Thanks for the assist.