mercredi 1 mars 2017

Dropzone.js "Undefined index: file" How to use with Laravel?

I'm using OctoberCMS, based on Laravel.

I have a working HTML form for uploading files.

<form class="dropzone" method="POST" action="/upload.php" enctype="multipart/form-data">

    <input type="hidden" name="_handler" value="onUpload" />

    <div class="fallback">
        <input type="file" name="file">
    </div>

    <input type="submit" value="Upload" />

</form>

Dropzone

I'm trying to add Dropzone.js to it. It says you just add the class to the form.

From Dropzone docs:
http://ift.tt/2mNdYF7

The uploaded files can be handled just as if there would have been a html input like this:

<input type="file" name="file" />

That's what my form type and name already was before adding Dropzone.

Error

But when it gets to this line in my upload.php, I get an error:

$inputName = basename($_FILES['file']['name']);
$inputExtension = pathinfo($inputName, PATHINFO_EXTENSION);

Error: Undefined index: file

But it worked before without Dropzone, using the same name 'file'.

Laravel

It will pass without error if using:

$inputName = Input::file('file');

But now I have difficulty getting the file extention, because it's no longer in the variable using Input::file.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire