{"id":406,"date":"2012-11-18T20:38:40","date_gmt":"2012-11-19T01:38:40","guid":{"rendered":"http:\/\/www.cloppermillweather.org\/blog\/?p=406"},"modified":"2012-11-23T23:40:35","modified_gmt":"2012-11-24T04:40:35","slug":"new-data-upload-method","status":"publish","type":"post","link":"https:\/\/www.cloppermillweather.org\/blog\/2012\/11\/18\/new-data-upload-method\/","title":{"rendered":"New Data Upload Method"},"content":{"rendered":"<p>I&#8217;ve been using FTP to transfer my weather data, statistics, and history to the cloppermillweather Web site.\u00a0 This has worked fairly well, but I didn&#8217;t want to be dependent on my ISP providing FTP.\u00a0 I knew I could create a PHP Web page to accept data.\u00a0 I thought I might be able to use wget to do an HTTP POST with the data files I wanted to upload.\u00a0 So I did some researching and discovered that curl was fully capable of doing what I wanted.\u00a0 So I created a simple PHP page to accept a file and modified my FTP scripts on my weather server to use curl instead of FTP.\u00a0 Everything is working great with a little less overhead than my prior FTP scripts.\u00a0 I also added some simple validity checks on the upload page to make sure the data is good.\u00a0 Not all that secure (at least not yet), but the concept works just fine.\u00a0 Here&#8217;s a generic curl comand to post a file:<\/p>\n<p>curl -F&#8221;operation=upload&#8221; -F&#8221;file=@fileToUpload&#8221; http:\/\/URLToReceiveHTTPPost<\/p>\n<p>One thing to watch out for is if the destination site sends back an HTTP 301 redirect.\u00a0 Curl has an option to follow the redirect and do a subsequent POST.\u00a0 Most browsers will follow the redirect but refuse to do the HTTP POST after the redirect.\u00a0 This is actually a security feature, so make sure you know where you are being redirected to before POSTing anything you want to keep private.\u00a0 Weather data probably isn&#8217;t something where privacy is a concern, but the warning applies if you are using this technique for other types of data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using FTP to transfer my weather data, statistics, and history to the cloppermillweather Web site.\u00a0 This has worked fairly well, but I didn&#8217;t want to be dependent on my ISP providing FTP.\u00a0 I knew I could create a &hellip; <a href=\"https:\/\/www.cloppermillweather.org\/blog\/2012\/11\/18\/new-data-upload-method\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-weather"],"_links":{"self":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":0,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloppermillweather.org\/blog\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}