LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-02-2005, 01:15 PM   #1
BmxFace
Member
 
Registered: Jun 2003
Location: Minnesota
Distribution: Arch Linux :D
Posts: 105

Rep: Reputation: 15
an upload program for apache?


hi, im looking to find a upload script type thing for users to upload photo's to my http server. im very new to this so i might have no idea what im talking about
 
Old 06-02-2005, 01:23 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
I have made one with perl.
The reciever.pl
Code:
#!/usr/bin/perl

use strict;

use CGI;
my $req = CGI->new;

print "Content-type: text/html\n\n";
print "Hello..."; 

my $nimi = $req->param('filefield');
print "Fetching.. file " . $nimi ."<br>";
my $tnimi = $nimi;
$tnimi =~ s/\.\./_/g;
$tnimi =~ s/\//_/g;
$tnimi =~ s/^\./_/g;
my $now = time();
$tnimi = $now . "_" . $tnimi;

print "Using name " . $tnimi . "<br>";

my $upload = $req->upload("filefield");


open UPLOADFILE, ">files/$tnimi";
binmode UPLOADFILE;
while(<$upload> ){
    print UPLOADFILE;
}
close UPLOADFILE;

print "<br>...done<br>";

And the corresponding web form:
Code:
<html>

<body>
<p>

        Give a new file!<BR>
        <form method="post" action="reciever.pl" enctype="multipart/form-data">
        <input type="file" name="filefield" size="50"><BR>
        <input type="submit" value="Send">
        </form>
        Hit the Send button once and wait.
</body>

</html>
Also to .htaccess you have to have:
Code:
Options +ExecCGI
AddHandler cgi-script .pl
 
Old 06-02-2005, 01:38 PM   #3
BmxFace
Member
 
Registered: Jun 2003
Location: Minnesota
Distribution: Arch Linux :D
Posts: 105

Original Poster
Rep: Reputation: 15
alright thank you but i honestly dont know how to add this...i mean the most i know how to do is manage html files and add directorys with apache :\
 
Old 06-02-2005, 03:17 PM   #4
BmxFace
Member
 
Registered: Jun 2003
Location: Minnesota
Distribution: Arch Linux :D
Posts: 105

Original Poster
Rep: Reputation: 15
alright i got it added and everything and i think i added that cgi thing to my httpd.conf correctly but when i click send. it just shows me the perl script, why is this?
 
Old 06-02-2005, 09:02 PM   #5
BmxFace
Member
 
Registered: Jun 2003
Location: Minnesota
Distribution: Arch Linux :D
Posts: 105

Original Poster
Rep: Reputation: 15
anyone please?
 
Old 06-03-2005, 10:09 AM   #6
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Do you have ExecCGI option enabled?
(eg. line 'Options +ExecCGI' in .htaccess, or ExecCGI in options-line in your httpd.conf)

Do you have 'AddHandler cgi-script .pl' line in place (in .htaccess or in httpd.conf)?

Is the reciever.pl flagged as executable?
(chmod +x reciever.pl)

Is cgi support enabled in your apache?
(In debian/apache2
Code:
ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/
). In other systems effectively having something like
LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
configure apache upload speed j-ray Linux - Software 4 12-18-2004 04:16 AM
is there any linux msn program that lets you download and upload files? Necronomicom Linux - Software 5 08-22-2004 02:04 AM
Help with FTP Upload to Apache Webserver kalikoder Linux - Networking 4 01-16-2004 08:25 PM
ftp upload program thegreatgatsby Linux - Software 3 10-31-2003 10:40 AM
file upload apache 2.0 scriptjunkie Linux - Newbie 0 08-08-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration