Allow_url_fopen - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Allow_url_fopen (/showthread.php?tid=16635) Pages:
1
2
|
Allow_url_fopen - El Forum - 03-12-2009 [eluser]Thiago Luiz[/eluser] Hi. In the structure of my site, I have a sub-folder that contains files. So I want these files available for download. Where the production server is located, allow_url_fopen is disabled. On my localhost, allow_url_fopen is enabled in my controller, I have a function with the contents like this: $ Data [ 'title'] = "Some Title"; $ This-> load-> helper ( 'download'); $ Path = base_url (). "path / to / files / file.extension"; $ Data = file_get_contents ($ path); // Read the file's contents $ Name = 'file.extension'; force_download ($ name, $ data); So, on my localhost it works, but in production server not. Anyone have any idea how I can access files with allow_url_fopen set to "OFF"? Allow_url_fopen - El Forum - 03-12-2009 [eluser]TheFuzzy0ne[/eluser] Are the files not on the same server as the script? Allow_url_fopen - El Forum - 03-12-2009 [eluser]Thiago Luiz[/eluser] Files are on the same server. Allow_url_fopen - El Forum - 03-12-2009 [eluser]Thiago Luiz[/eluser] I develope on my localhost and when application is ok, I upload the application to production server. Allow_url_fopen - El Forum - 03-12-2009 [eluser]drewbee[/eluser] Are you using absolute path IE /path/to/my/file.ext or full url? http://mysite.com/path/to/my/file.ext Allow_url_fopen - El Forum - 03-12-2009 [eluser]pistolPete[/eluser] Don't use base_url() because the "path" will result in something like http://example.com/path/to/file.ext. It's the setting you specified in application/config/config.php: Code: $config['base_url'] = ... Either use relative paths or some of the constants defined in index.php. Allow_url_fopen - El Forum - 03-12-2009 [eluser]TheFuzzy0ne[/eluser] Then wouldn't force_download() in the download helper be ideal? You shouldn't need to utilize any URLs when serving up files from the localhost, it will probably slow things down. as you are transferring the file over the network when it's not needed. It's a bit like walking out of your front door and around your house, through your back door just to get to the kitchen, when you could have just taken a shorter route. Allow_url_fopen - El Forum - 03-12-2009 [eluser]Thiago Luiz[/eluser] I think not explained clearly. I develop the application in my computer. When the application is ready, I transfer it to the production server. I usually use: www.domain.com / controller / function just in the controller function have the following content as I said before: $ Data [ 'title'] = "Some Title"; $ This-> load-> helper ( 'download'); $ Path = base_url (). "Path / to / files / file.extension"; $ Data = file_get_contents ($ path); / / Read the file's contents $ Name = 'file.extension'; force_download ($ name, $ date); This works on my computer where I develop the application, but to transfer the application to the production server access to files generates the following error: A PHP Error was encountered Severity: Warning Message: file_get_contents () [function.file-get-contents]: URL file-access is disabled in the server configuration Filename: controllers / mycontroller.php Line Number: 396 Furthermore, I could see that the variable allow_url_fopen in production server where the application is set to OFF. The team responsible for the Administration of the site, said it will not change the setup of this variable. Allow_url_fopen - El Forum - 03-12-2009 [eluser]TheFuzzy0ne[/eluser] I still don't get it... Code: $Path = base_url (). "Path / to / files / file.extension"; Allow_url_fopen - El Forum - 03-12-2009 [eluser]Thiago Luiz[/eluser] This part relates to some news of the site and some news are files that I put in a sub-folder on production server. OK, I agree with you and pistolPete when you say not to use base_url(). Am I doing something wrong encoding to show the way? |