开发者

problems with php file_get_contents and FIle length

I've wrote a simple api that bring together data from one server to the other. its a very simple $_GET based api where all the data is appended as GET data to the url.

So I get something like: http://example.com/api.php?param1=afdsa&param2=TTTT&....etc.

In order to call it I use file_get_contents($url); first of all - I don't really need the content of the reply. I just need to "touch" the url so it will kick into action.

I had problems with my hosting (shared, justhost) and I've moved along to a VPS. I've started to get timeout on my api calls and when I've checked the apache error.log I've saw:

"failed to open stream: File name too long in ..."

And indeed - the $url string is around 450 chars.

The question is - where do I change the setting for the file length. Its not the same as the Hard drive file system because my own computer get the same string with no problems and with no errors. also - the shared hosting did not have any problems with that url.

The VPS runs ubuntu 10.04 lts with PHP Version 5.3.2-1ubuntu4.9

Appreciate any h开发者_运维技巧elp, been sitting on that for two days

SOLVED

Well you know how is it when you think you know where the problem is but its not? well - that was the problem. I've rewritten my API so all it will do is print_r($_GET); and what do you know - it worked fine. So I've started to add the lines one by one and found out that what stacked the script was a php mail function. Why? I don't know, maybe mail setting are not correct - but now, when I've commented out the mailing - all works fine.

It still doesn't explain my "file to long" error, but never mind. Thanks to you all


It looks like your URI is too long.

Relevant: What is the maximum length of a URL in different browsers?

Consider using CURL to POST your variables to api.php


Your problem not in file_get_contents, but in fopen or other function, which trying to create file. It can be caching system - can't say without code. In other words, problem not in length of url - only in length of the name of file.
failed to open stream - it's error message from file handler.
Length of URL not limited, and even if limited by the server (e.g. apache), it will not be warned as error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜