FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php upload problem





takashiro
That is the source code.
Code:
<html>
<head>
<title>uploading fiels</title>
</head>
<body>
<div>
<form enctype="multipart/form-data" name=myform method="post" action="upload.php">
upload:<input name="myfile" type="file"> <br />
<input name="submit" value="upload" type="submit">
</form>
</div>
<?php
if(isset($submit)){
if($myfile!= "none"){
$upload_dir = "E:\yufeng\upload1";
$up=copy($myfile,$upload_dir);
if($up==1){
print("file was uploaded successfully!");
}
else {
print("uploading failed!");
}
unlink($myfile);
}
else{
print("You haven't select any files!");
}
}
?>


</body>
</html>


But it did not work well,
Code:
Warning: copy(E:\yufeng\upload1) [function.copy]: failed to open stream: Permission denied in E:\yufeng\upload.php on line 16
kv
This should work.

Code:

<html>
<head>
<title>uploading fiels</title>
</head>
<body>
<div>

<form enctype="multipart/form-data" name=myform method="post" action="upload.php">
upload:<input name="myfile" type="file"> <br />
<input name="submit" value="upload" type="submit">
</form>
</div>


<?php

if( if(!empty($_FILES["myfile"])) )
{
   $upload_dir = "E:\yufeng\upload1\";
   $uploadfile = $uploaddir . basename($_FILES['myfile']['name']);

   if(move_uploaded_file($_FILES["myfile"]["tmp_name"], $uploadfile))
   {
      print("file was uploaded successfully!");
   }
   else
   {
      print("uploading failed!");
   }
}
else
{
   print("You haven't select any files!");
}

?>

</body>
</html>


Basically, you can't use the file variable in the post request like a normal post variable (you need to use global $_FILES). Also, you cannot use copy function (use move_uploaded_file instead).
Related topics
php upload issue
I need a php upload script, NEEDED BADLY
File upload problem :'(
[PHP] Upload de arquivos
FTP upload problem
phpmyadmin upload problem
[RESOLVED] php file upload problem
php upload problems
PHP script problem
Stats problem - php execution problem (MOD Assist Required)
PHP upload Max
How to build simple PHP upload form
php msql problem
php mail(); problem... half fixed?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.