rseigel Posted April 23, 2013 Share Posted April 23, 2013 I have the following line: PHP Code: copy ('http://www.azuregreenw.com/StockInfo.csv', 'AG.csv'); It works with other suppliers I grab inventory files from but not this one. The file is not copied. I've added this to the top of my script: ini_set('post_max_size', '16M'); ini_set('upload_max_filesize', '16M'); This file is 1.31 MB if that makes a difference.Their phpinfo file is at http://www.azuregreenw.com/phpinfo.phpDoes anyone know what may stop it from copying and what I might be able to do to make it work? Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 23, 2013 Share Posted April 23, 2013 You should really be using move_uploaded_file(). http://us3.php.net/manual/en/function.move-uploaded-file.php Always make sure to include error handling in your code. Check to make sure the file was uploaded successfully before copying it. If you post your code it would be easier to see where the problem may be. Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 23, 2013 Author Share Posted April 23, 2013 (edited) Thanks for your answer. Does it matter that the file I'm moving is on a remote server? In other words....I'm trying to copy/move/whatever a csv file from my suppliers website to mine. Edited April 23, 2013 by rseigel Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 23, 2013 Share Posted April 23, 2013 If the file is being uploaded to the server it is being saved on, no. The way you have worded the process is a little confusing. You ARE using a form to upload a file, right? Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 23, 2013 Author Share Posted April 23, 2013 No. Let me try to be clearer. My supplier has a daily updated file that they store on their server. It essentially is for updating inventory counts on my web site. I'm trying to get that file (by any means possible) and use it to update my inventory. I have the code in place that will do that. I'm just having trouble copying the file from their server to mine. Hopefully that makes more sense. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 23, 2013 Share Posted April 23, 2013 If it's a public URL, you can use file_get_contents() to load it into memory. It will return a false value if it wasn't able to download the entire file. After you have checked the success, you can save it using file_put_contents(). Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 23, 2013 Author Share Posted April 23, 2013 So..... $csv = file_get_contents('http://www.azuregreenw.com/StockInfo.csv'); if ($csv === false) { echo 'File not good!'; } else { echo $csv; } Gets me the response: File not good! Where to next? Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 23, 2013 Share Posted April 23, 2013 My first guess is that you have error reporting off and you've reached the max memory_limit. Try adding this above your code: error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 23, 2013 Author Share Posted April 23, 2013 This is what I have so far: error_reporting(E_ALL); ini_set('memory_limit', '4096M'); $csv = file_get_contents('http://www.azuregreenw.com/StockInfo.csv'); if ($csv === false) { echo 'File not good!</br>'; } else { echo $csv; } No other erros are thrown. Just: File not good! I'm at a loss at this point. Thanks for all the help. Hopefully this creates an aha moment for someone. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 24, 2013 Share Posted April 24, 2013 I'm guessing your web server doesn't like PHP trying to allocate that much memory. Try a lower number like 128M. That should be more than enough. Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 24, 2013 Author Share Posted April 24, 2013 Tried that as well. Same result. This should be s o simple. I'm doing the exact same thing with 2 other suppliers so far. Is it possible it's something to do with their configuration on their end? Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 24, 2013 Share Posted April 24, 2013 It IS possible, but more likely to be a memory constraint by your server. I know you say no errors are thrown, but when file_get_contents() fails, it should at least be throwing a warning. I think your server configuration is preventing them from being displayed altogether. Try adding this above your code: ini_set('display_errors', 1); Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 24, 2013 Author Share Posted April 24, 2013 Finally we have a error message to deal with. Warning: file_get_contents(http://www.azuregreenw.com/StockInfo.csv): failed to open stream: Connection timed out in /home1/aonewebs/public_html/AG_inventory_update.php on line 45 Does this mean there's nothing I can do unless I can convince my supplier to whatever controls that? Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 24, 2013 Author Share Posted April 24, 2013 Looking at their server config: max_execution_time 30 memory_limit 32M Do either or both of these create a problem? Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 24, 2013 Share Posted April 24, 2013 (edited) Interesting. Are you behind a proxy? What happens if you change the URL to just http://www.google.com? Those two config settings shouldn't cause any problems. Does the owner of this website know you are doing this? It is possible they banned your IP simply because you were using too much bandwidth. Edited April 24, 2013 by lemmin Quote Link to comment Share on other sites More sharing options...
rseigel Posted April 24, 2013 Author Share Posted April 24, 2013 Not behind a proxy. If I change the URL it brings up a local version of google's home page. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 24, 2013 Share Posted April 24, 2013 I have to guess that the server is explicitly rejecting your server. Can you telnet that server from your web server? What happens if you try to put a different URL from that server into your file_get_contents() function? 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.