This is only a minor script, I have something bigger in mind. But I figured I should make sure uploading files from a computer to the server using PHP works first before going further...and GUESS what...I seem to be having a problem with it 😐
I got this script info from php.net under copy() just modified it a bit...heres my code:
<HTML>
<TITLE>File Upload</TITLE>
<BODY>
<form enctype="multipart/form-data" action="<?PHP echo $PHP_SELF ?>" method="post">
Send this file: <input name="userfile" type="file">
<input type="submit" name="submit" value="Send File">
</form>
</BODY>
<?
$dir="/";
if(isset($submit)) {
copy($userfile,$dir.$userfile_name);
if(!is_uploaded_file($userfile)){
echo "<b>$userfile_name</b> couldn't be copied!";
}
}
if(is_uploaded_file($userfile)){
echo "<b>$userfile_name</b> copied successfully!";
echo "<br>$dir<br>$userfile<br>$userfile_name<br>";
}
?>
</HTML>
Script seems to be working, yet it doesn't.
When it's ran, it'll say the file was copied successfully, yet there is no file found in the directory......so it must not be working right.
However, I think, THINK (hehe), I know whats wrong, but I don't know why its comming up or how to fix it. Under if(is_uploaded_file.... I put echo "<br>$dir<br>$userfile<br>$userfile_name<br>"; so it'll echo back the variables...well this is what I get >
Send this file:
elipse.php copied successfully!
/
/var/tmp/phpdTAAPf
elipse.php
For $userfile, it lists /var/tmp/phpdTAApf...I'm assuming that is wrong heh...but I could be wrong, I don't know...
Anyone have any ideas what IS wrong?