Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File data missing #9

Open
tomorrowevening opened this issue Aug 20, 2014 · 1 comment
Open

File data missing #9

tomorrowevening opened this issue Aug 20, 2014 · 1 comment

Comments

@tomorrowevening
Copy link

ofxHttpForm form;
form.action = "http://localhost:8888/upload.php";
form.addFormField("userID",  ofToString(userID));
form.addFile("file", "log.txt");
form.method = OFX_HTTP_POST;
http.addForm( form );
$user  = $_POST["userID"];
echo "User:  " . $user;
echo "\n";
echo "POST: " . count($_POST) . "\n";
echo print_r($_POST);
echo "\n\n";
echo "FILE: " . count($_FILE) . "\n";
echo print_r($_FILE);

Result:

User:  0
POST: 1
Array
(
    [userID] => 0
)
1

FILE: 0
1

POST variables get sent over, but why don't I see anything added through ofxHttpForm's::addFile()?

@tomorrowevening
Copy link
Author

PHP required the absolute path of the destination, thanks to this link, now works!

<?php

$uploaddir = '/Users/colind/Projects/C++/openFrameworks/projects/Server/bin/data/logs/';

if (is_uploaded_file($_FILES['file']['tmp_name'])) {
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);
    echo "File ". $_FILES['file']['name'] ." uploaded successfully. ";
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
        echo "File is valid, and was successfully moved. ";
    } else
        print_r($_FILES);
} else {
    echo "Upload Failed!!!";
    print_r($_FILES);
}

?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant