I have a upload file,it works fine in my computer on my server, but , when my friend tried it, it dosen't work. Can you tell me why?thanks!!my code is here:
<html>
<head>
<title>
</title>
</head>
<?php
$file_url="http://www.llama.phpwebhosting.com/FunPicSite/Uploads";
$file_dir="/home/llama/www/FunPicSite/Uploads";
print"<b>Picture Information:</b><br>";
foreach($HTTP_POST_FILES as $file_name=>$file_array) {
print "path:".$file_array['tmp_name']."<br>\n";
print "name:".$file_array['name']."<br>\n";
print "size:".$file_array['size']."<br>\n";
print "type:".$file_array['type']."<br>\n";
$type=$file_array['type'];
if( is_uploaded_file($file_array['tmp_name'])&&( $type=="image/gif" || $type=="image/pjpeg"||$type=="image/x-png" ) )
{
$tmpname=$HTTP_POST_FILES['UploadPic']['tmp_name'];
$name=$HTTP_POST_FILES['UploadPic']['name'];
move_uploaded_file($tmpname,"$file_dir/".$name)or die("couldn't copy");
print"<img src=\"$file_url/$name\"><br>";
print "<b>Picture name:</b>$uname";
}
else{ print"Error!";}
}
$dberror=" ";
add_to_database($uname,$name,&$dberror);
function add_to_database($uname,$name,&$dberror){
$user="llama";
$pass="osti";
$db="funpic";
$link=mysql_connect("localhost",$user,$pass);
if(!link)
{
$dberror="couldn't connect to MYSQL server";
return false;
}
if(!mysql_select_db($db,$link)) {
$dberror=mysql_error();
return false;
}
$query="INSERT INTO PicInfo(name,filename)
values('$uname','$name')";
if(!mysql_query($query,$link)){
$dberror=mysql_error();
return false;
}
return true;
}
?>
<body>
<form enctype="multipart/form-data" method="POST" action="<?php print $PHP_SELF?>">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="UploadPic" >The picture should not be bigger than 50kb<br>
<input type="text" name="uname">Type the picture's name<br>
<input type="submit" value="upload">
</form>
</body>
</html>