Spiral's avatar

How to upload randomly file from local

I want to upload a random file which will select from computer and upload?

0 likes
7 replies
ftiersch's avatar

Pretty sure you can't just upload a random file. The user has to select the file in a dialog - everything else would be a gigantic security risk.

What you could do is let the user select (for example) 10 files and then upload a random one of those.

1 like
Spiral's avatar

@oli_d111 Thanks for replying me...

I want that user select a file when click on the button then which will a json format then decode

Spiral's avatar

Yes @ftiersch brother Thanks for replying me>>

Myy randomly mean is that user select a file from their computer

i want to get this file from storage so that i will decode them and import into database

ollie_123's avatar
Level 6

Hey @spiral

As @ftiersch said, the user needs to upload the file in a form. This is normally done via an <input type="file" id="file" name="file">

The controller would then take the file and you would specify the path in which to place the file for safe keeping. After that you would extract the file name and write the file name to one of the columns in your database. (You wouldn't normally store it directly into the database.)

To call upon the file you would send the data from the controller to the view file and then place an anchor tag so that the user can download. Something along the lines of

<a download href="{{ URL::to('/') }}/yourfolder/{{ $yourvariable->column_name }}">Download</a>

Did you check out the tut i sent a link for earlier?

1 like
ollie_123's avatar

Hey @spiral did you manage to get it sorted?

If so please can you mark my answer as "Best Answer" to close the thread.

Please or to participate in this conversation.