How to upload to PHP server

0 favourites
  • 1 posts
From the Asset Store
You can upload screenshots and photos to your server very easily.
  • After weeks searching and not finding anything, I thought and found a solution, no gambiarra of turning images I base64 or something like.

    It's simple, you add File Choose and a button.

    Add the Web plugin and when you start the layout you put it to execute as javascript command:


    $(function () {
     var form;
     $('#fileUpload').change(function (event) {
     form = new FormData();
     //var name =[0]; extenção
     $('#btnEnviar').click(function () {
     url: 'URL', // URL of your server
     data: form,
     processData: false,
     contentType: false,
     type: 'POST',
     success: function (data) {
     // return

    Remember to set the ID of the file chooser to 'fileUpload' and from the button to 'btnEnviar' or another of your own, but do not forget to change the js code as well.

    In php:

     $file_name = $_FILES['fileUpload']['name'];
     $file_size = $_FILES['fileUpload']['size'];
     $file_type = $_FILES['fileUpload']['type'];
     $temp_name = $_FILES['fileUpload']['tmp_name'];
     $location = "../imagens/";
     move_uploaded_file($temp_name, $location . $file_name);
     echo "done";
     echo "Error";

    That's it, it's very easy to.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)