473,671 Members | 2,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading data from HTTP POST method

270 Contributor
Hello,
I'm beginner to php (actually i'm java/jsp developer),
What i'm trying to do is Accept parameters from the HTML file and write them to a newly created file using php,
I wrote following script but it doesn't work,

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $uploaddir = '/var/www/vhosts/nitinsawant.com/subdomains/httpdocs/files/';
  4. $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  5.  
  6. echo '<pre>';
  7. if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
  8.     echo "File is valid, and was successfully uploaded.\n";
  9. } else {
  10.     echo "Possible file upload attack!\n";
  11. }
  12.  
  13. echo 'Here is some more debugging info:';
  14. print_r($_FILES);
  15.  
  16. print "</pre>";
  17.  
  18. ?>
for passing parameters to the php script I'm using following HTML file,
post.html
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head>Post data...</head> 
  3. <body> 
  4. <form action="post.php" method="POST"> 
  5. ID: <input type="text" name="ID"/><br/>
  6. Data: <textarea cols=35 rows=15 name="data"></textarea> 
  7. <br/> 
  8. <br/> 
  9. <input type="submit" value="submit" /> 
  10. </form> 
  11. </body> 
  12. </html>
  13.  
I want to create file named "ID" at server side and append the "data" to the file.

help me.

regards,
Nitin Sawant
May 9 '09 #1
5 3101
Markus
6,050 Recognized Expert Expert
Check out the file system functions, namely fopen(), fwrite() and fclose().

Also, you are not submitting files via your form so using $_FILES is pointless. You need to be using $_POST.
May 9 '09 #2
NitinSawant
270 Contributor
Thanks a lot, for posting the links.
May 10 '09 #3
Markus
6,050 Recognized Expert Expert
@NitinSawant
You're welcome.

Mark.
May 10 '09 #4
v08i
2 New Member
For file uploads to work, your html form should have enctype attribute set to multipart/form-data. Like this:

Expand|Select|Wrap|Line Numbers
  1. <form action="post.php" method="POST" enctype="multipart/form-data" >
  2.  
May 23 '09 #5
indesulsenift
1 New Member
hey. finally signed up as a member after some time of just lurking and reading posts.

merry xmas to all!
Dec 25 '10 #6

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

Similar topics

0
1367
by: Row | last post by:
HI, I would first like to say its been about 3 years since looking at java im very rusty! I have to write a post it notes type applet which will function online. (reading from a flat text file) My main problem is: getting each paragraph into my vector array - so that each paragraph sits in a new array element. Eg: when i referance array elemant 2 it will give me paragraph which is in that element and not all paragraphs in the text file...
6
6596
by: Dietrich Epp | last post by:
Are there any good modules for reading a bitstream? Specifically, I have a string and I want to be able to get the next N bits as an integer. Right now I'm using struct.unpack and bit operations, it's a bit kludgy but it gets the right results. Thanks in advance.
2
1447
by: | last post by:
Hi, I was using the Reader class to read a binary file and I noticed that there is no PeekByte and also its not optimised when using Peek and Read in sequence. If the .Peek is called its read the next char, and then .Read after its reading twice, why cant the .Read use the stored Peek internally? It would be twice as fast.
5
17386
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. string get_url = "http://scmvs4:9090/gtccinfo/H485W020.HTML"; --url contains a form string post_url = "http://scmvs4:9090/cgi-bin/gticglnk/P485VEGA"; --called by get_Url upon submit
7
6055
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an error. Can I ask a simple question to start with: I'm trying to read the file using the...
16
4180
by: bloggsfred00 | last post by:
I need to read incoming bytes on a COM port but I do not want to have the script hang if there is nothing to read. Is there any way to have PHP interrogate a COM port buffer to see if there is any content before reading it? Any other method to achieve the result would also be welcome. Cheers,
4
3250
by: David | last post by:
Hi, (Sorry for duplicate post, finger trouble before I finished...) using C# 1.1 I am writing a winform app that collects a dataset from a webservice. At the same time I collect the data, I write the dataset out to the local disk using DataSet.WriteXml, so that if the webservice is not available,
5
2345
by: menriquez | last post by:
Hi...I am trying to write a test html/php app that accepts some POSTed XML data and replies with (for now) an echo of the $_POST array. Here is my index.htm.. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>XML POST Test v1.0</title> </head> <body> <form id="Form1" action="POST" method="post.php">
1
4410
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I would give it a try. First of all, I am using Visual Studio 2005 to write my program. I am using C# .NET as the language. I am running Windows XP Professional with all service packs and updates applied. Now, I have been trying to write a...
0
8473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.