Re: No data?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In reading over LOAD DATA ... in the mysql reference. it makes
particular note of the fact that the file it's reading must be
completely world readable, including all paths to the file. In
checking just now, I notice that a file uploaded by php and placed in
/tmp is only readable by the server user (aka, www-data on some
systems).

   "For security reasons, when reading text files located on the
server, the files must either reside in the database directory or be
readable by all."
<http://dev.mysql.com/doc/refman/5.1/en/load-data.html>

This tiny script shows what happens:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html><head><title>file upload example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>file upload example</h1>

<h2>$_FILES</h2>
<pre>
  <?php var_dump($_FILES); ?>
</pre>

<?php
   if (count($_FILES)>0) {
     $lscmd = 'ls -l '.$_FILES['userfile']['tmp_name'];
     echo '<h2>ls -l tmp_name</h2>'.PHP_EOL;
     echo '<pre>'.`$lscmd`.'</pre>'.PHP_EOL;
   }
?>


<form enctype="multipart/form-data" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>

</body>
</html>

When a file is submitted, this is the output:

file upload example
$_FILES

  array(1) {
  ["userfile"]=>
  array(5) {
    ["name"]=>
    string(15) "testfile.txt"
    ["type"]=>
    string(10) "text/plain"
    ["tmp_name"]=>
    string(14) "/tmp/phphxGoQm"
    ["error"]=>
    int(0)
    ["size"]=>
    int(4244)
  }
}

ls -l tmp_name

-rw------- 1 www-data www-data 4244 Jul 26 04:41 /tmp/phphxGoQm

Send this file: <form stuff shows up here>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux