LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-22-2014, 01:11 PM   #1
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Rep: Reputation: Disabled
Question regarding file upload to a server (using a web-browser)


Hi,
I'm trying to set up a simple file upload page, using httpd and cgi-bin.
Basically, what I'm missing is a way to “grab” the variable name (for lack of a better term), of the uploaded file.
I'm using a bash based cgi script.

On the web page I have:

Code:
<FORM method="POST" enctype="multipart/form-data" action="/cgi-bin/upload.sh">
<input type="file" name="file_name" size="20">
The webpage does not error, but – I can see in the logs that I am not able to “grab” the file name in any way. I assumed that resulting file name/descriptor/value would have been “file_name”, but, I cannot do anything in the cgi-script by relating to “file_name” .
Any help is most appriciated.

Thank you .
 
Old 06-22-2014, 04:34 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
See something like http://oinkzwurgl.org/bash_cgi ?
 
Old 06-22-2014, 05:41 PM   #3
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
See something like http://oinkzwurgl.org/bash_cgi ?
Thank you unSpawn,
I've stumbled upon a similar page in my searches. And, I assume this could get the job done, though I do not understand each line in this code, I get the majority of lines' meaning.

I believe there should be a simpler solution (I'd prefer to use one which I fully understand).
For example, with other cases, the value after “name= “ has been always sufficient with passing the value of data entered, from the webpage, to the CGI script. I assume, it should take less than an rather complicated script in order to achieve so.
(Perl has some useful facilities, but it's not a grand type of solution I'm looking for).
 
Old 06-23-2014, 03:13 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I'm sure an easier script is a possibility, esp. since the file name should be somewhere in the variables the web server receives. Can you make BASH print those like you would with
Code:
foreach $key (sort keys(%ENV)) {
  print "$key = $ENV{$key}<p>";
}
 
Old 06-23-2014, 08:39 PM   #5
G_A
LQ Newbie
 
Registered: Jun 2014
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
I'm sure an easier script is a possibility, esp. since the file name should be somewhere in the variables the web server receives. Can you make BASH print those like you would with
Code:
foreach $key (sort keys(%ENV)) {
  print "$key = $ENV{$key}<p>";
}
Mm.. I am not sure if bash "sees" the same vars (or var names) which php does. Don't know much about it. The best that I know is, to follow the "name" value , in the <input > definitions. It served me well so far, [ but not now ]
 
  


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
Web server with public IP address not reachable via domain name in the web browser floorripper Linux - Server 11 08-09-2013 09:55 PM
[SOLVED] Light Weight Web Browser/File Browser CincinnatiKid Linux From Scratch 16 06-27-2012 01:37 PM
On the web browser and File>Save As>Web Page, HTML only. stf92 Linux - Newbie 4 12-18-2010 04:21 AM
Test HTML file locally with my browser before posting it on a WEB server mcanallyd Linux - Newbie 2 06-06-2009 10:01 PM
web server (fedora core 5) became read-only file system after i upload a file nggs8411 Linux - Server 1 03-26-2007 09:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:07 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