Page 1 of 1

Send info through POST

Posted: Mon Nov 20, 2006 2:58 pm
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>

Posted: Mon Nov 20, 2006 3:02 pm
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).

Posted: Mon Nov 20, 2006 3:03 pm
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?

Posted: Mon Nov 20, 2006 3:06 pm
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>

Posted: Mon Nov 20, 2006 3:16 pm
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?

Posted: Mon Nov 20, 2006 3:21 pm
by Burrito
fullname 8O

Posted: Mon Nov 20, 2006 3:56 pm
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... :(

Posted: Mon Nov 20, 2006 4:00 pm
by feyd
enctype should be multipart/form-data.

Note the added dash.

Posted: Mon Nov 20, 2006 4:05 pm
by Maluendaster
feyd wrote:enctype should be multipart/form-data.

Note the added dash.
if i add that dash, it will not work...

Posted: Mon Nov 20, 2006 4:07 pm
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>

Posted: Mon Nov 20, 2006 5:51 pm
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?