Page 1 of 1

problem in uploading files from my form in php

Posted: Sat Jul 28, 2007 1:48 am
by shankar_nsm
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am new to php programming and i am having  a problem in uploading a file to the server from my form can anybody help me in this context.  I am sending the code that i have written along with the error message it is showing.

Code: Select all

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }

  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
	   echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
	  }
	}

?>
the error message is:

Warning: move_uploaded_file(upload/filenames.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\akuva\upload.php on line 32 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php28B.tmp' to 'upload/filenames.txt' in C:\Inetpub\wwwroot\akuva\upload.php on line 32


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Jul 28, 2007 6:21 am
by superdezign
What are the permissions of the folder you are trying to move the upload to?