I'm trying to create a standard web form that will use a PHP script
to copy a file from one server to another.
Both servers have the files in publicly accessible directories.
The html form I'm using follows...
<form name="form" method="post" action="server2server.php">
Enter the filename you wish to copy.<br><br>
<input type="text" name="trakname">
<br><br>
Enter the directory at mydomain.net where this file should be placed.<br><br>
<input type="text" name="dirname">
<br><br>
<input type="submit" name="Submit" value="Copy the File">
</form>
The PHP script I'm calling with that form follows...
<?php
if(!@copy('http://mydomain.com/files/".$_POST['trakname']."','/".$_POST['dirname']."/".$_POST['trakname']."'))
{
$errors= error_get_last();
echo "COPY ERROR: ".$errors['type'];
echo "<br />\n".$errors['message'];
} else {
echo "File copied from remote!";
}
?>
I'm receiving an "unknown T string" error on that line, but don't
know where or what that may be.
The same PHP script does work quite well for the purpose when used
with static data, so the problem seems to be an incorrect method of
inputting a form variable.
The PHP script that works follows...
<?php
if(!@copy('
http://someserver.com/somefile.zip
','./somefile.zip'))
{
$errors= error_get_last();
echo "COPY ERROR: ".$errors['type'];
echo "<br />\n".$errors['message'];
} else {
echo "File copied from remote!";
}
?>
I hope someone may be willing to help me correct my form input
problem, or suggest a better method of copying a file, input from an
html form, from one server to a directory, also specified through the
form, on the local server where the script is being called from.
Many thanks in advance for any suggestions. I've been messing with
this for days without discovering where my error comes from.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php