I am 95% of the way to uploading a file to my webspace. All of the AppGameKit side is done and successful, I can see from echoing the information on my web server that the file arrived OK.
From this point I use Naphier example code. This suggests that I received the file into the /tmp/ folder but I don't see it there. It then tells me that the folder doesn't exist when trying to move it, but I don't know if it is referring to the source or destination folder.
Here is the code that Naphier contributed:
if ($_FILES["myfile"]["error"] > 0){
echo "Error: " . $_FILES["myfile"]["error"] . "\n";
}
else {
echo "Upload: " . $_FILES["myfile"]["name"] . "\n";
echo "Type: " . $_FILES["myfile"]["type"] . "\n";
echo "Size: " . ($_FILES["myfile"]["size"] / 1024) . " Kb\n";
echo "Stored in: " . $_FILES["myfile"]["tmp_name"] . " \n";
if (file_exists("upload/" . $_FILES["myfile"]["name"]))
{
echo $_FILES["myfile"]["name"] . " already exists. \n\n";
}
else
{
move_uploaded_file($_FILES["myfile"]["tmp_name"], "/upload/" . $_FILES["myfile"]["name"]);
echo "Stored in: " . "/upload/" . $_FILES["myfile"]["name"] . " \n\n";
}
}
Here is the response:
Upload: admin20150906_210246.png
Type: application/x-zip-compressed
Size: 1.490234375 Kb
Stored in: /tmp/phpYMe2rY
<b>Warning</b>: move_uploaded_file(/upload/admin20150906_210246.png) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in <b>/home/MySite/public_html/revolution/upload/scoreup.php</b> on line <b>44</b><br />
<b>Warning</b>: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpYMe2rY' to '/upload/admin20150906_210246.png' in <b>/home/MySite/public_html/revolution/upload/scoreup.php</b> on line <b>44</b><br />
I have tried with both the full path and the subdomian path, neither work.
I used
/upload/ rather than
upload/ in this example but have tried both unsuccessfully.
Once I get this sorted I'd be happy to share a couple of extras if anybody is interested:
Protecting the upload with a hash key (prevents upload of malicious files)
Verifying user against a Joomla (or other) database.