File input doesn't have a value, do it like :
{{ Form::file('image', array('id' => 'img_add')) }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to add an id to my file
This is what I have
{{ Form::file('image', '', array('id' => 'img_add')) }}
but it seems that it doesn't work like that.
File input doesn't have a value, do it like :
{{ Form::file('image', array('id' => 'img_add')) }}
Awesome, thanks. Is there a way to get a name to it. I'm busy creating a drag and drop for my site. I have the drag and drop working but I need to save the image to the database.
This is the code in the create.blade.php for the upload
<div class="this-img" id="img_add">Upload </div>
@cmgmyr - That didn't work
I am not sure what you mean by "adding a name to it" if you want to create something like
<input name="my_file" type="file" id="img_add">
then use
{{ Form::file('my_file', array('id' => 'img_add')) }}
the first parameter is the input file name.
This is what originally had in my create.blade.php
{{ HTML::style('css/uploadfile.css') }}
{{ HTML::script('js/jquery.uploadfile.js') }}
<script>
var settings = {
url: '{{ asset("upload/upload.php") }}',
dragDrop:true,
multiple : false,
showFileCounter:false,
showDone: false,
fileName: "myfile",
allowedTypes:"jpg,png,gif,pdf",
//returnType:"json",
showDelete:true,
}
</script>
<div class="this-img" id="img_add">Upload </div>
var uploadObj = $("#img_add").uploadFile(settings);
That allows for me to drag and drop my files and the "Upload" is displayed as text on the site, but this code doesn't save to the database, so what I would like to do is have the "Upload" that is between
<div class="this-img" id="img_add">
and
</div>
be shown as text on the site by using
{{ Form::file('image', array('id' => 'img_add')) }}
which allows for me to save to the database. I want to merge the two together. Does that make sense?
Any ideas
So I slightly changed my create.blade.php to have this
<div id="fileuploader">
Upload
{{ form::file('image', array('class' => 'fileImage')) }}
</div>
<script>
$(document).ready(function()
{
$("#fileuploader").uploadFile({
url:'{{asset("upload/upload.php") }}',
fileName:"myfile"
});
});
</script>
My file is being uploaded to the correct place but I'm still not able to save my image to the database.
url:'{{asset("upload/upload.php") }}',
I'm not sure how much we'll be able to help you if you're just using a procedural PHP script.
Please or to participate in this conversation.