473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Sending file content

Hi all!

I have a problem, in HTML there is a form input type = "file", but somehow it returns only a filename, without it's content. Could you help me, to send file's content to any CGI script, so that it was possible to save it.


Huge thanks!
Jun 10 '07 #1
8 1859
drhowarddrfine
7,435 Expert 4TB
Show us what you've done so far. It should work.
Jun 10 '07 #2
That is a HTML part: (I guess there is an error)

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4.   <meta content="text/html; charset=ISO-8859-1"
  5.  http-equiv="content-type">
  6.   <title></title>
  7. </head>
  8. <body>
  9. <form enctype="text/plain" method="post"
  10.  action="load.cgi" name="someform"><input
  11.  name="file" type="file"><input name="send"
  12.  value="send" type="submit"></form>
  13. </body>
  14. </html>
PS. Somehow I returns only filename, but without content. And by the way, if you find an error, how fill look content like? I mean where sould script look for content? In this form it returns: send=<somefilename> . How will be content marked?

Here is an example how it works at the moment:
file=av-230.jpg&send=send
When script reads that post data, the only thing it can do, is just to write empty file with given filename. But I also need file content, because writing of empty file is aimless.

About script side.
Script is written on C++. I reads "post" data, searches for required values and then operates with them. I'm not sure, but maybe script has to request content of file separately? If it's so, then, how can it be done?
Jun 10 '07 #3
drhowarddrfine
7,435 Expert 4TB
When you click on 'browser', the name of the file is put into the text box but clicking 'send' only submits what is in the text box. The reason is that 'submit' is only attached to the text box and not the file itself.

Here is a good tutorial on what you want to do.
Jun 10 '07 #4
jhardman
3,406 Expert 2GB
Umm, I'm not absolutely sure about your system, but I thought all you had to do was change the enctype:
[html]ENCTYPE="multipart/form-data"[/html]
and then access that input as binary data rather than text.

I work in vbscript (so I'm not sure how easily this will translate to c++) but I just need to do
Expand|Select|Wrap|Line Numbers
  1. request.binaryread(request.form("myFileInput"))
rather than
Expand|Select|Wrap|Line Numbers
  1. request.form("myFileInput")
which is what I would use for any other input. If I use the latter I just get the file name returned.

Jared
Jun 12 '07 #5
drhowarddrfine
7,435 Expert 4TB
It's not C++, it's CGI. What he's talking about is a html element that does this work.
Jun 12 '07 #6
jhardman
3,406 Expert 2GB
It's not C++, it's CGI. What he's talking about is a html element that does this work.
Yes, I got the part where he said his CGI script was written in c++.

Regardless, a lot of software venders like to sell complicated solutions for file upload, but all you have to do to make the browser send the entire file is to change the enctype
[html]<form method="post" action="/cgi-bin/formHandler" enctype="multipart/form-data">[/html]

This will send all of the form including the entire file inputted. However, if you access that input the same way as everything else you will still only get the name of the file. You need to access that part of the posted data differently, which is why I showed how I do it in asp. The difference is significant, I just don't know how this will translate to a c++ cgi script.

Jared
Jun 12 '07 #7
OK, It's understood.

Then I just need to find a way of binary reading.

Huge thanks to all of you guys!
Jun 12 '07 #8
jhardman
3,406 Expert 2GB
OK, It's understood.

Then I just need to find a way of binary reading.

Huge thanks to all of you guys!
There is another option as well, now that I think of it. Your server can be set to save uploaded files in a designated folder. I've actually never looked into that, though...

Jared
Jun 12 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Kubaton Lover | last post by:
I have a pdf file (syllabus.pdf) on the server. I have written the following PHP code. It correctly finds the file, but it is sending the file back as text I think because I'm seeing the binary...
9
by: Gregor Rot | last post by:
Hi, i am sending a pdf file to IE6 and just want the browser to open it directly without asking anything. This doesn't work: Content-type: application/pdf Content-length: size_of_file...
3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
3
by: Ot?vio | last post by:
Hi! I'm havin a problem about sending a binary file with fsockopen. My problem is solved when i do: -------------------->8------CODE----------------------------- <form...
2
by: Frostillicus | last post by:
I'm trying to get an ASP to return a zip file to the remote browser from an Image (BLOB) field in SQL Server 2000 but Internet Explorer keeps saying: Cannot open C:\Documents and...
7
by: 3KWA | last post by:
Hi all, I tried to send a small mailing list using python today (2036 emails). For that purpose I looked in the doc for some code examples (I had never done it before). And I ended up writing...
0
by: kencana | last post by:
Hi all, I got problem in sending email with image file attached. the problem is that i can't see the image, apart from that i also try to attach a txt file and it gave me no luck. the txt file in...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
1
by: runway27 | last post by:
<?php $headers = "Content-type: text/html; charset=iso-8859-1"; $to="myemailaddress"; $subject="Email Newsletter"; $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.