Re: Subject: file upload into mySQL

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

 



Something is wrong with your query : Imagine - you are sending a file to MySQL from the $_FILES array. And I think , that the syntax is wrong (it should be files["filename"]["tmp_name"] cause this is a temporary file).

Also it is likely that MySQL does not have permissions to access the temporary file uploaded, which will be owned by the web server process, not by the MySQL process.

Now .... how do you suppose MySQL is expected to know which columns you want to send ?

It might try to insert into the b_col column, but what should it do with the other 3 columns ? You see, you should not specify INFILE unless there is a 1-1 correspondence of fields in the File, to fields in the DB.

Even then, lines in the File should probably be recognised with a newline character to indicate the end of a record (such as CSV files). You have not specified any delimiters. So the query is almost guaranteed to fail, especially with possibly binary files.

I would load the $_FILES["uploaded_file_name"]["tmp_name"] into PHP and check that you have received what you expect. Then use the value in this variable to make your query.

Cheers - Neil.

At 21:14 25/12/2003 +0000, you wrote:
create table objects
         b_col blob,
         name varchar(30),
         file_size varchar(30),
         file_date datetime
}


-------------testform.php------------- <form method="post" action="upload.php" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="512000"> <input type="file" name="UploadedFile"><br> <input type="submit" value="SEND"> </form> ----------------------------------------------------


-------upload.php-------- $db = mysql_connect("localhost", "*****", "***"); mysql_select_db("*****",$db); $sql_insert = "LOAD DATA LOCAL INFILE '$HTTP_POST_FILES[$UploadedFile]'INTO TABLE objects"; mysql_query($sql_insert);

-- 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