Good afternoon,
I am trying to upload a file by managed_file.
The source code is like below.
$form['photo'] = array(
'#type' => 'managed_file',
'#upload_location' => 'public://upload/teacher/photo'
);
And I want to update the photo realtime which I don't know how to.
Once you select a file, the file will be automatically uploaded into server.
I want to get the event handlers of javascript. so I can show the uploaded image.
I am trying to do something like below and I know it's not right way.
$("#edit-photo-upload").change(function() {
I searched internet a lot to find some answers, but I cannot.
I want to know how to
- delete the record of managed_file when the file is removed from webbrowser.
- update/show uploaded file data in real time.
- show progresss bar
- upload multi-files
Please give me tip if someone knows about it.
Thank you.
Comments
Re: Drupal 8 Managed file
From the local_image plugin of the Drupal 8 Advanced Tour. However, this was from last March and its likely to have changed.
hi slewazimuth
hi slewazimuth
im using you code for upload a image but i have thes error "Fatal error: Call to a member function getFilename() on null" and the result of var_dump($imageid); the result is NULL i dont now whay
myclass
the image has uploded in sites\default\files\images
and $imageid return NULL too
Thank you.
That code is very old and no
That code is very old and no longer being used. Uploading is now happening inside specific plugins.
Here's a snippet of something more recent.
Hope it helps. (Don't worry about the thumbnail signalling code as it has no bearing on uploading.)
create a module contact form whit code from content type already
ah thankyou for helping but i have other question plz
I want to create Module (a contact form ) with code from content type already created from the back-office, i want to start creating but i dont know how, if some one know how plz help :D
thank you.
the content type hase
a title
email
name
message
Here is a link to many
Here is a link to many examples which will help you: https://www.drupal.org/project/examples
file_load() is deprecated in D8
file_load() method in deprecated in D8. So is this the correct approach to manage files in D8 ?
file_load() simply became
file_load() simply became \Drupal\file\Entity\File::load() and far as the previous code goes $file = file_load($imageid[0]); became $file = \Drupal\file\Entity\File::load($imageid[0]); which for that code works fine. Could it have been written differently? Of course it could. In this case correct or incorrect was simply does it work or not.