Send info through POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Send info through POST

Post by Maluendaster »

hi, how can i send info like this .
I want to pass info from a form that has only one item (file) , for examlpe, when i tried i want to pass all the info (c:\program files\info.rar) but it only pass info.rar

Code: Select all

<form action="top.php" method="post">
  <input type="file" name="fila" />
  <br />
  <input type="submit" name="Submit" value="Submit" />
  <br />
  </label>
  <label></label>
</form>
and this is the one that recives it.

Code: Select all

<form  method="post" name="add" action="http://www.fastshare.org/upload.php" enctype="multipart/form-data" onSubmit="FormularbuttonVeraendern(this.SendenButton);">
 <input type="hidden" name="MAX_FILE_SIZE" value="">
<table border=0 align=center>
 <tr>
  <td align=center></td>
 </tr>
 <tr>
   <td align=center><label>
     <input name="textfield" type="text" value="<?php echo $_POST['fila'] ?>">
   </label></td></tr>
 <tr>

  <td align=center><input name="SendenButton" type="submit" value="Upload" accesskey="s"></td>
  <span id="warning"></span> </tr>
</table>
</form>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could fetch the value of the file field and set a hidden form var to it (using js).

I'm not sure that PHP grabs all of that info on the server side (other languages do).
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Burrito wrote:you could fetch the value of the file field and set a hidden form var to it (using js).

I'm not sure that PHP grabs all of that info on the server side (other languages do).
i barely know php, don't know how to do it.. is it to hard?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

untested

Code: Select all

<script>
function getFullPath()
{
  document.getElementById('fullname').value = document.getElementById('somefile').value;
   return true;
}
</script>

<form name="MyForm" method="post" enctype="multipart/formdata" onSubmit="return getFullPath">
<input type="hidden" name="fullname" id="fullname">
<input type="file" name="somefile" id="somefile">

</form>
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Burrito wrote:untested

Code: Select all

<script>
function getFullPath()
{
  document.getElementById('fullname').value = document.getElementById('somefile').value;
   return true;
}
</script>

<form name="MyForm" method="post" enctype="multipart/formdata" onSubmit="return getFullPath">
<input type="hidden" name="fullname" id="fullname">
<input type="file" name="somefile" id="somefile">

</form>
thanks, which name is the one i should pass to the top.php to get the full path?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

fullname 8O
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

Burrito wrote:fullname 8O
ok, it worked only in IE, doesn't work with firefox... i have a problem, when change the type="text" (which is wrong), to type="file" (which is correct), it doesnt work... :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

enctype should be multipart/form-data.

Note the added dash.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

feyd wrote:enctype should be multipart/form-data.

Note the added dash.
if i add that dash, it will not work...
Last edited by Maluendaster on Mon Nov 20, 2006 5:48 pm, edited 3 times in total.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

tested this in both ff and ie...works

Code: Select all

<?
if(isset($_POST['fullname']))
	echo $_POST['fullname']."1";
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
<script>
function getFullPath()
{
  document.getElementById('fullname').value = document.getElementById('somefile').value;
   return true;
}
</script>
</head>

<body>


<form name="MyForm" method="post" enctype="multipart/form-data" onSubmit="return getFullPath()">
<input type="hidden" name="fullname" id="fullname">
<input type="file" name="somefile" id="somefile">
<input type="submit" value="test">

</form> 


</body>
</html>
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

http://www.multiupload.net - check it , everythng is working, but when i click the upload button in top.php, it will not upload, and if i change the type from text to file in the form of top.php , it will not get the fullname variable. anyway to fix this?
Post Reply