Get File, File Name and Additional Fields From Q-Uploader in Server Side



  • Hi, so I’m having a bit of a problem when using Q Uploader. I’m trying to upload an image and send some additional data with the request to a PHP file, this is what I have:

    <q-uploader
    extensions=".png"
    method=“POST"
    name=“image”
    :additionalFields=”[{‘data’: my_data_variable}]"
    float-label="Actualizar Foto de Perfil"
    color=“dark”
    :url= "getRootURL + ‘app/upload-img’"
    style=“margin: 30px;”
    />

    I’m using PHP on my server side, which is where I want to perform the image upload, this is what I have:

    *$extension = mb_strtolower(end(explode(’.’, $_FILES[‘image’][‘name’]))); // trying to get image extension

    if($extension == “png”):
    if(move_uploaded_file($_FILES[‘image’][‘tmp_name’], “/images/folder/” . $_POST[‘data’] . “.png”)){
    echo “true”;
    }else{
    echo “false”;
    }
    endif;*

    However, this is giving me the following errors:

    [22-Sep-2017 21:19:39 America/Mexico_City] PHP Strict Standards: Only variables should be passed by reference in /my-site/upload_image.php on line 1
    [22-Sep-2017 21:19:39 America/Mexico_City] PHP Notice: Undefined index: data in /my-site/upload_image.php on line 4

    Anyone know why I’m getting these errors and how I can go about fixing them? What I want to do is get the value of the additional ‘data’ variable passed in from the and move the uploaded image to the images folder, I’m currently using $_FILES[‘image’][‘tmp_name’] to try to get the image and move it to the folder.



  • try to do it as follows
    <q-uploader: url = “url”: headers = “headers”: additionalFields = “additionalFields”>

    additionalFields: [
               {
                 name: ‘user_id’,
                 value: ‘1’
               }
             ]


Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.