Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:roxlu/ofxCurl
- Loading branch information
Showing
16 changed files
with
156 additions
and
4,455 deletions.
There are no files selected for viewing
Binary file not shown.
1,429 changes: 0 additions & 1,429 deletions
1,429
example/mac_xcode/curl.xcodeproj/diederick.mode1v3
This file was deleted.
Oops, something went wrong.
1,896 changes: 0 additions & 1,896 deletions
1,896
example/mac_xcode/curl.xcodeproj/diederick.pbxuser
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions
90
example/ofxcurl_upload_file_and_handle_response/testApp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "testApp.h" | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::setup(){ | ||
ofBackground(33); | ||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::update(){ | ||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::draw(){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::keyPressed(int key){ | ||
if(key == 't') { | ||
// Create a form. | ||
ofxCurl curl; | ||
ofxCurlForm* form = curl.createForm("http://ofxcurl_upload_test.localhost/upload.php"); | ||
|
||
// Add some form entries. | ||
form->addInput("name", "Diederick Huijbers"); | ||
form->addInput("email","diederick_AT_apollomedia.nl"); | ||
form->addInput("secret", "call me roxlu"); | ||
form->addFile("photo",ofToDataPath("image_to_upload.png",true)); | ||
|
||
// Perform the post. | ||
try { | ||
form->post(); | ||
} | ||
catch(...) { | ||
cout << "OOPS.. something went wrong while posting" << endl; | ||
} | ||
|
||
// Do something with the response from the post. | ||
vector<char> response_buf = form->getPostResponseAsBuffer(); | ||
string response_str = form->getPostResponseAsString(); | ||
cout << "Size of response buffer: " << response_buf.size() << endl << endl; | ||
cout << "Response string:" << endl; | ||
cout << "-----------------" << endl; | ||
cout << response_str <<endl; | ||
|
||
// Cleanup | ||
delete form; | ||
} | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::keyReleased(int key){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::mouseMoved(int x, int y ){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::mouseDragged(int x, int y, int button){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::mousePressed(int x, int y, int button){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::mouseReleased(int x, int y, int button){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::windowResized(int w, int h){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::gotMessage(ofMessage msg){ | ||
|
||
} | ||
|
||
//-------------------------------------------------------------- | ||
void testApp::dragEvent(ofDragInfo dragInfo){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* What follows is a very very basic upload handler. This is just an example | ||
* how one can handle uploaded files. I created this tiny script to test the | ||
* file upload of ofxCurlForm and handling of the response. | ||
* | ||
* | ||
* @author Diederick Huijbers <diederick_AT_apollomedia.nl> | ||
* @date 2011.07.20 | ||
*/ | ||
function l($s) { | ||
file_put_contents('log.txt', date('Y-m-d',time()) ."\t" .$s ."\n", FILE_APPEND); | ||
} | ||
function e($s) { | ||
echo $s ."<br>"; | ||
} | ||
|
||
$upload_dir = dirname(__FILE__) .'/uploads/'; | ||
$upload_path = $upload_dir .$_FILES['photo']['name']; | ||
if(move_uploaded_file($_FILES['photo']['tmp_name'], $upload_path)) { | ||
l("photo: ". basename( $_FILES['photo']['name'])); | ||
} else{ | ||
l('photo: cannot upload'); | ||
} | ||
l('name: ' .$_POST['name']); | ||
l('email: ' .$_POST['email']); | ||
l('secret: ' .$_POST['secret']); | ||
l('------------------'); | ||
echo 'name=' .$_POST['name'] ."\n"; | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters