file upload problem from Win2k client - to Linux PHP4 server...
| From: | Seasundown at aol dot com | Date: | Fri, 22 Dec 2000 05:26:18 +0000 |
| Subject: | file upload problem from Win2k client - to Linux PHP4 server... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-31540@lists.php.net to get a copy of this message | ||
Problem:
No temp file to be copied over to the server is ever copied to my local Win2k
client
filesystem in c:\tmp. Consequently, it is never transported (uploaded) to my
Linux
system where the server resides. What could I possibly be doing wrong?
Forever in your debt.
TIA!!!!!
Here is php script (applicable parts) residing on Linux
Apache PHP4 server. It calls script which follows this one
from a win2000 browser wanting to upload a file to Linux:
##########################################################
<HEAD>
<TITLE>PHP - file upload</TITLE>
<style type="text/css">
<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
-->
</style>
</HEAD>
<center>
<table>
<FORM ENCTYPE="multipart/form-data"
ACTION="http://216.35.187.73/php/upload_go.php"
METHOD=POST>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
<tr>
<td>file upload</td>
<td></td>
</tr>
<tr>
<td>file: </td>
<td><input type="File" name="userfile" size="30"
maxlength="255">
</td>
</tr>
<tr>
<td>target filename: </td>
<td><input type="Text" name="newname" size="30"
maxlength="^255">
</td>
</tr>
<tr>
<tr>
<td>upload diretory: </td>
<td>php</td>
</tr>
<td colspan="2" align="CENTER">
<INPUT TYPE="submit" VALUE="upload">
</td>
</tr>
</FORM>
</table>
</center>
##########################################################
Here is upload_go.php file on same php4 server - Linux -
apache which is called by the above page from browser on win2000.
##########################################################
<?php
function do_upload($filename,$newname) {
echo (" HAPPY \n");
print ( " bef bname filename: $filename \n");
$file = basename($filename);
print ( " after bname file: $file \n");
print ( " userfile $userfile \n" );
# $tmp_upload_path = "c:\\apache\\htdocs\tmp\\";
$tmp_upload_path = "c:\\tmp\\";
# $new_file_name = "c:\\apache\\upload\\".$newname;
$new_file_name = "c:\\tmp\\$newname";
# if (!copy($tmp_upload_path.$file,$new_file_name)) echo "copy fail\n";
if (!copy($tmp_upload_path.$file,$new_file_name)) echo "copy fail\n";
print ( " $new_filename_name is new_filename_name \n" );
print ("filename: $filename - filename: $newname is newname \n");
return;
}
?>
<HEAD>
<TITLE>PHP - file upload</TITLE>
<style type="text/css">
<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
-->
</style>
</HEAD>
<?php
print (" userfile is $userfile \n" ) ;
do_upload($userfile,$newname);
print (" userfile is $userfile \n" ) ;
?>
<TABLE>
<TR>
<TD>upload report</TD><TD></TD>
</TR>
<TR>
<TD>upload tmp file:</TD><TD><?php echo $userfile; ?></TD>
</TR>
<TR>
<TD>file name:</TD><TD><?php echo $userfile_name; ?></TD>
print (" userfile_name $userfile_name \n ") ;
</TR>
<TR>
<TD>target file name:</TD><TD><?php echo $newname; ?></TD>
</TR>
<TR>
<TD>target directory:</TD><TD>/usr/local/httpd/docs/php</TD>
</TR>
<TR>
<TD>file size:</TD><TD><?php echo $userfile_size; ?></TD>
</TR>
<TR>
<TD>file type:</TD><TD><?php echo $userfile_type; ?></TD>
</TR>
</TABLE>
###########################################################
Here are print & error messages after pressing
upload button. bbbbb... was given as new file name
and test.html was uploaded to the dialogue box from
the file system seemingly appropriately.
###########################################################
userfile is /tmp/phpbb5ILq
bef bname filename: /tmp/phpbb5ILq
after bname file: phpbb5ILq
userfile
Warning: Unable to open 'c:\tmp\phpbb5ILq' for reading: No such file or
directory in
/usr/local/httpd/doc/php/upload_go.php on line 13
copy fail
is new_filename_name
filename: /tmp/phpbb5ILq - filename: bbbbbbbb is newname
userfile is /tmp/phpbb5ILq
print (" userfile_name $userfile_name
\n ") ;
upload report
upload tmp file:
/tmp/phpbb5ILq
file name:
test.html
target file name:
bbbbbbbb
target directory:
/usr/local/httpd/docs/php
file size:
257
file type:
text/html