View Single Post
  #5  
Old 7th November 2005, 18:46
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for looking at this problem. Unfortunately these changes did not fix my problem. I may not have stated it correctly, although it does appear to be in the php.ini configuration files. I tired to shotgun this problem and frankly I have confused myself. Let me regroup. The application is designed to upload a tab delimited file, and then move the file to a known directory where it will be used to recreate a database table. In order to accomplish this I use the following code snippets (see example code). This code allowed me to upload the file to the phptmp directory, but not move it to another directory (my first problem, see error message 1). I tried changing permissions on the target directory, but it still did not work. Trying to isolate the problem I changed the code to copy to a known file name within the phptmp directory. This worked, but them MySQL would not use the file as input to a load data command because of permissions (see error message 2). Also this is not the solution I wanted, because it did not save the file in a designated directory. Finally, I needed to change permissions for MySQL to work and inform the client of the status by listing his uploaded directory. I need to use some system commands to accomplish this task. I have attached output from a working example to demonstrate what I am trying to accomplish.

Questions: Where is the php.ini changed to make the local column different than the default column? How does this occur?

Is there any other documentation on php.ini file except in the examples of the default?

Example Code (snippets)
// to upload the file …
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $myfile)) {
echo 'Problem: Could not move file to destination directory';
exit;
}
}
else {
echo $tab.$tab.'Problem: Possible file upload attack. Filename: ';
echo $_FILES['userfile']['name'];
exit;
}

//to create the database…
$cmd = "chmod 0666 ".$myfile; // input file for database creation
exec($cmd);
echo "Loading ".$load.".txt<br />";
$mysql = db_nameconnect("Bacchus");
$query = "TRUNCATE ".$load;
$result = dbquery( $query, $mysql );
echo "myfile ".$myfile."<br />";
$query = "LOAD DATA INFILE '$myfile' INTO TABLE ".$load; // into database
$result = dbquery( $query, $mysql );
echo "Successfully loaded file in ".$myfile." <br />";
echo "to $load table in Bacchus database<br /><hr><br />";
mysql_close($mysql);

Error message 1.
Problem: Could not move file to destination directory
output file = /home/web8/uploads/auth.txt
input file = /var/www/web8/phptmp/php0mYQNW

Error message 2.
MYSQL error was: The file '/var/www/web8/phptmp/auth.txt' must be in the database directory or be readable by all

Example working output:
Uploading file...
Selected file is auth.txt
File uploaded successfully

Preview of directory contents:
________________________________________
-rw-r--r-- 1 apache apache 2275 Nov 3 17:59 auth.2005-11-03.06:08:40
-rw-r--r-- 1 apache apache 2275 Nov 3 18:08 auth.2005-11-07.10:18:45
-rw-r--r-- 1 apache apache 2275 Nov 7 10:18 auth.txt
-rw-r--r-- 1 apache apache 199519 Oct 23 11:52 inventory.2005-10-23.12:05:45
-rw-r--r-- 1 apache apache 176081 Oct 23 12:05 inventory.2005-10-23.12:09:43
-rw-r--r-- 1 apache apache 179385 Oct 23 17:29 inventory.txt
-rw-r--r-- 1 apache apache 217754 Oct 24 07:28 learnmore.2005-10-24.07:30:01
-rw-r--r-- 1 apache apache 217754 Oct 24 07:30 learnmore.2005-10-24.07:39:04
-rw-r--r-- 1 apache apache 217754 Oct 24 07:39 learnmore.zip
________________________________________
Installing file...
________________________________________

Loading auth.txt from myfile /uploads/bb/auth.txt
Successfully loaded file in /uploads/bb/auth.txt to auth table in Bacchus database
________________________________________
Reply With Quote