BeerNut 25 Posted June 21, 2016 Report Share Posted June 21, 2016 I am trying to get one of my posts to simply post cvs files to my server and then have my server save them. I am using HTTP Post and the $http upload command and php on my server to handle the saving. But no mater how much i simplify the code it never works. At this point I need a second pair of eyes on the problem so I can stop hitting my head into the wall. Here is the uBot Code set(#uploadFile,$plugin function("HTTP post.dll", "$http upload", "http://www.mysite.com/upload.php", "", $plugin function("File Management.dll", "$open file dialog"), "rawData", "file", "", "", "", ""),"Global") Here is the upload.php on the server <?php $currentdir = getcwd(); $target = $currentdir .'/upload/' . basename($_FILES['rawData']['name']); move_uploaded_file($_FILES['rawData']['tmp_name'], $target); ?> Has anyone else done this and had success? Could it be something server side causing the problems? Thanks guys. Quote Link to post Share on other sites
abbas786 78 Posted June 21, 2016 Report Share Posted June 21, 2016 Use this php code for debugging echo '<pre>'; if (move_uploaded_file($_FILES['rawData']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; Also, use fiddler to check the data you are sending to the server. It will help u to understand the error. Quote Link to post Share on other sites
BeerNut 25 Posted June 21, 2016 Author Report Share Posted June 21, 2016 Fiddler captures no data from the $http upload the log is always blank. And the Debugging info is always empty as seen below. <pre>Here is some more debugging info:Array() Quote Link to post Share on other sites
abbas786 78 Posted June 21, 2016 Report Share Posted June 21, 2016 OK, so basically you are not using the Upload Function Properly. Please use the code below. You are sending wrong content type. set(#uploadFile,$plugin function("HTTP post.dll", "$http upload", "https://httpbin.org/post", "", $plugin function("File Management.dll", "$open file dialog"), "rawData", "image/jpeg", "", "", "", 120),"Global") Content Type: JPG Image: image/jpegGIF Image: mage/gifPNG Image: mage/pngTEXT File: text/plainCSV File: text/csvJSON File: application/jsonHTML File: text/htmlXML File: application/xml Quote Link to post Share on other sites
BeerNut 25 Posted June 22, 2016 Author Report Share Posted June 22, 2016 Still does not work. Nothing uploaded via $http upload gets accepted or has any data in the $_FILES array. I have sent Aymen a support ticket and sent him the link to this topic. Maybe he will be able to help. If I use a simple html page to post files to the php script everything works fine. Its just that any data sent via $http upload is just empty. Below is the simple html code to send files. <!DOCTYPE html> <html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="rawData" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </body> </html> I tried the $http upload code with the following content types "application/vnd.ms-excel""text/csv""multipart/form-data"and"image/jpeg" when trying to upload a jpg instead. Full php script that accepts the files with debuging is below <?php $uploaddir = realpath('./') . '/uploads/'; $uploadfile = $uploaddir . basename($_FILES['rawData']['name']); echo '<pre>'; print_r($uploaddir); echo "\n<hr />\n"; print_r($uploadfile); echo "\n<hr />\n"; if (move_uploaded_file($_FILES['rawData']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo "\n<hr />\n"; echo 'Here is some more debugging info:'; print_r($_FILES); echo "\n<hr />\n"; print_r($_POST); print "</pr" . "e>\n"; ?> Quote Link to post Share on other sites
BeerNut 25 Posted June 23, 2016 Author Report Share Posted June 23, 2016 Well Aymen sent me a screen cast of him using my exact code and everything worked fine. I can only assume at this point that I might have some sort of conflict with my setup in general that breaks it. So if anyone else wants working code to do this its in this topic. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.