enveetee Posted February 17, 2015 Share Posted February 17, 2015 I am trying to upload a large dataset in CSV format for batch loading into a MYSQL table using LOAD DATA INFILE The CSV file (test.csv) is in /var/services/web/php My table is in /var/services/mysql/TABLENAME When I run the SQL command from a PHP script I get an error ERROR: Can't get stat of '/var/services/mysql/TABLENAME/test.csv' (Errcode: 2) Which I believe is because the file needs to be in /var/services/mysql/TABLENAME. Indeed, if I move it there, it works fine If I try and use the LOCAL switch LOAD DATA LOCAL INFILE I get an error stating that feature is not available. Research shows it can cause a security hole and needs to be enabled separately, something I am not prepared to do I cant copy the file in my PHP script to /var/services/mysql/TABLENAME as it is outside or /var/services/web So short of manually copying the FTP'd file to my table directory, how could I copy it from my PHP script? This also leads to my second question 'how do I access files outside my web root' Thanks Quote Link to comment Share on other sites More sharing options...
CroNiX Posted February 17, 2015 Share Posted February 17, 2015 (edited) The php user for that site, or the group the user belongs to, needs to have read/write permissions for whatever dir they are trying to access outside of that users "home". Well probably just read permissions if you are manually uploading the file. Otherwise any php user on the server, for any website, can read/write each others files, which is like NO security. Edited February 17, 2015 by CroNiX Quote Link to comment Share on other sites More sharing options...
enveetee Posted February 17, 2015 Author Share Posted February 17, 2015 @CroNix not sure I understand your answer... I don't have a 'php user' Its just a website with php scripts. The scripts can be executed by any browser Quote Link to comment Share on other sites More sharing options...
raphael75 Posted February 17, 2015 Share Posted February 17, 2015 (edited) PHP runs under a certain user account. On Linux it's usually www-data (which is what apache usually runs under, and thus PHP). But this could be different. On Windows/IIS it's usually IUSR_MACHINE. Whatever the user account is, it has to have permission to access the file. Edited February 17, 2015 by raphael75 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.