Koozali.org: home of the SME Server

PHP Question

Anonymous

PHP Question
« on: March 25, 2004, 09:31:21 AM »
Hi All,

This is probably more of a PHP question, but I wonder if anyone here can help.

I have 2 php scripts - a form and a script file that is suposed to upload a file to a directory on my website.  I'm pretty sure the code is OK, but the script dosen't work.  Is there some security setting in SME 5.6 that might cause this?  The target directory is a sub directory off wwwroot and has permissions set to 777 and is owned by Admin.

This is the form...

<html>
<head>
<title>Upload Form</title>
</head>
<body>
<form action="upload_file_script.php" enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
File to Upload: <input type="file" name="fileupload"><br><br>
<input type="submit" value="upload!">
</form>
</body>
</html>


And this is the upload script...

html>
<head>
<title>File Upload Script</title>
<html>
<head>
<title>Upload script</title>
</head>
<body>
<h1>File Upload Results</h1>
<?php
$file_dir = "/Intranet/files";

foreach($_FILES as $file_name => $file_array) {
   echo $file_dir;
   print "<br>\n";
   print "path: ".$file_array['tmp_name']."<br>\n";
   print "name: ".$file_array['name']."<br>\n";
   print "type: ".$file_array['type']."<br>\n";
   print "size: ".$file_array['size']."<br>\n";

   if (is_uploaded_file($file_array['tmp_name'])) {
      move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die ("Couldn't copy");
       print "file was uploaded!<br><br>";
   }
}
?>
</html>


Any ideas? Thanks in advance!

Dave

Offline wyron

  • *
  • 275
  • +0/-0
    • http://www.ideast.dk
PHP Question
« Reply #1 on: March 25, 2004, 10:37:11 AM »
If changing the ownership to www:www doesn't help, I have no better idea.
Greetings
wyron
...

David_White

directory path
« Reply #2 on: March 25, 2004, 11:12:56 AM »
OK - I have just figured it out.  You need to use the full path to the target directory, not the path relative to wwwroot. ie use

/home/e-smith/files/primary/html/Intranet/files

not

/Intranet/files

Whew!

Cheers

Dave

Offline wyron

  • *
  • 275
  • +0/-0
    • http://www.ideast.dk
Re: directory path
« Reply #3 on: March 25, 2004, 01:39:15 PM »
Quote from: "David_White"
OK - I have just figured it out
Dave

Silly me for not realising that. I even had a similar problem some time ago, with a guestbook in one of the sites i host for friends.
I must be growing old !
Greetings
wyron
...