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
Maluendaster
Forum Contributor
Posts: 124 Joined: Fri Feb 25, 2005 1:14 pm
Post
by Maluendaster » Mon Nov 20, 2006 2:58 pm
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>
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Mon Nov 20, 2006 3:02 pm
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 » Mon Nov 20, 2006 3:03 pm
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?
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Mon Nov 20, 2006 3:06 pm
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 » Mon Nov 20, 2006 3:16 pm
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?
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Mon Nov 20, 2006 3:21 pm
fullname
Maluendaster
Forum Contributor
Posts: 124 Joined: Fri Feb 25, 2005 1:14 pm
Post
by Maluendaster » Mon Nov 20, 2006 3:56 pm
Burrito wrote: fullname
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...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Nov 20, 2006 4:00 pm
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 » Mon Nov 20, 2006 4:05 pm
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.
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Mon Nov 20, 2006 4:07 pm
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 » Mon Nov 20, 2006 5:51 pm
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?