{"id":177,"date":"2014-12-18T07:55:31","date_gmt":"2014-12-18T07:55:31","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=177"},"modified":"2014-12-17T18:05:43","modified_gmt":"2014-12-17T18:05:43","slug":"php-include-remote-file","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/php\/php-include-remote-file\/","title":{"rendered":"PHP include Remote File"},"content":{"rendered":"<p>In some case it might be needed to include or run a remote file and display the output on the current site. For this to work the below settings needs to be enabled.<\/p>\n<pre class='wp-code-highlight prettyprint'>\r\n    allow_url_fopen = On\r\n    allow_url_include = On\r\n<\/pre>\n<p>But in case those two settings cannot be changed or even after changing it doesn&#8217;t work (which happened for me) there is another way. See the main part.<\/p>\n<pre class='wp-code-highlight prettyprint'>\r\n    var yname =  document.getElementById(\"yname\").value;\r\n    var email = document.getElementById(\"email\").value;\r\n    var subject = document.getElementById(\"subject\").value;\r\n    var mesg = document.getElementById(\"mesg\").value;\r\n    \r\n    \r\n\/******************  MAIN PART *******************\/\r\n    var url = \"http:\/\/www.remote-server.com\/mails.php?yname=\" + yname + \"&email=\" + email + \"&subject=\" + subject + \"&mesg=\" + mesg;\r\n   \r\n    mailer = document.createElement(\"script\");\r\n    mailer.setAttribute('type', 'text\/javascript');\r\n    mailer.setAttribute('src', url);\r\n    mailer.setAttribute('id', 'script_id');   \r\n    document.getElementById(\"mailer_holder\").appendChild(mailer); \r\n\/****************** End of MAIN PART *******************\/\r\n    \r\n    alert(\"Mail Sent Successfully\");\r\n    document.getElementById(\"yname\").value = \"\";\r\n    document.getElementById(\"email\").value = \"\";\r\n    document.getElementById(\"subject\").value = \"\";\r\n    document.getElementById(\"mesg\").value = \"\"; \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In some case it might be needed to include or run a remote file and display the output on the current site. For this to work the below settings needs to be enabled. allow_url_fopen = On allow_url_include = On But in case those two settings cannot be changed or even after changing it doesn&#8217;t work&hellip; <a class=\"more-link\" href=\"https:\/\/www.kolkataonweb.com\/code-bank\/php\/php-include-remote-file\/\">Continue reading <span class=\"screen-reader-text\">PHP include Remote File<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-php","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":2,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/177\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}