I'm using fine-uploader with AngularJS. This is the configuration I am using in my HTML file:
<div fine-uploader
upload-server="{{ uploadServer }}"
not-available-placeholder="/vendor/jquery.fine-uploader/placeholders/not_available-generic.png"
waiting-placeholder="/vendor/jquery.fine-uploader/placeholders/waiting-generic.png"
max-file-size="10000000"
large-preview-size="500"
allowed-mimes="image/jpeg, image/png"
allowed-extensions="jpeg, jpg, png"
token="{{ token }}">
</div>
How do I:
Handle file upload errors? For example, I would like to display a custom AngularJS dialog when an upload error happens. Is there any sample code that illustrates how to do this? I already have my own dialog code I can call.
Limit the number of retries to 1?
Related
i am facing strange issue. When i upload the image(jpg,jpeg,png) file using livewire its working fine but when i try to upload any other file type its giving me error this error This driver does not support creating temporary URLs. Not sure is livewire doesnot support to upload doc, docx, pdf, csv xls, xlsx if yes its very strange?. Or i am doing something wrong in code. here is my below code:-
<form wire:submit.prevent="save">
<input type="file" wire:model="documnet">
#error('documnet') <span class="error">{{ $message }}</span> #enderror
<!-- Progress Bar -->
<div x-show="isUploading">
<progress max="100" x-bind:value="progress"></progress>
</div>
<div wire:loading wire:target="save">Uploading...</div>
<button type="submit">Save documnet</button>
</form>
In this user input any type of document (jpg, jpeg, png , doc, docx, pdf, csv xls, xlsx ). Here is my below component code
public function save(){
$extension = $this->document->getClientOriginalExtension();
// Filename to store
$fileNameToStore = uniqid().'_'.time().'.'.$extension;
// Upload Image
$path = $this->document->storeAs('public',$fileNameToStore);
}
Can anyone help me what i am doing wrong or livewire not supports to upload these extensions?
publish the config file with,
php artisan livewire:publish --config
Then add mime type of file you want to upload to preview_mimes under the temporary_upload_file in config file.
Supported file types for temporary file urls are set in:
config/livewire.php temporary_file_upload->preview_mimes array for support
How would you go about creating a button in your templates of an app in Django. I have a script in my views.py:
def my_python_script(request):
if request.is_ajax:
# stuff here
else:
return HttpRequest(status=400)
But how do I actually turn this into a button? Is there some html or css I need to put somewhere? I saw some things about a templates directory in the application but I'm unsure on what things to put there and in what formats.
You would do like the following:
<button type='button' id="my_button">Click me</button>
And with a js (jquery):
$("#my_button").click(){
$.get("url_to_view",{data:"data",function(response){
// response to do something after the request
});
});
I'm using this bootstrap-fileinput plugin to upload file in my WebApp.
To develop this WebApp I'm using: Bootstrap4, Thymeleaf and Spring Boot.
I would like to use the html5 convenction to use that plugin, so this is the code:
<div class="file-loading" >
<input id="uploadPDF" type="file" class="file" data-theme="fas" data-allowed-file-extensions='["pdf"]'
data-language="it" data-type="POST" th:data-upload-url="#{/path/{id}/pdf(id=${myObject.id})}"/>
</div>
But I enabled the CSRF protection with Spring Security. So when I try to upload a pdf the result is:
Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.
I would like to add the CSRF token using the HTML5 convection, so something like:
<input .... data-toke="token"...>
In this way I can avoid to use the javascript.
Is it possible?
You can access the value of the csrf token with ${_csrf.token}. So:
<input ... th:data-token="${_csrf.token}" ... />
I'm building a Ruby web app with Sinatra, and am using a form to pass parameters to a POST page, which should have rendered dynamic content based on those parameters.
However, when it came time to test the POST method and submitting the form, the following was displayed in the browser:
Internal Server Error
bad content body
When this happens, the error log shows:
Error: EOFError: bad content body
followed by a stacktrace of files I'm not working with and then:
"POST /list/AUser'sName" HTTP/1.1 500 294
Code for the form:
Note - This page is just used for redirecting to a different page, determining the correct form action= attribute.
<form action="/list/<%=name%>" method='post' enctype="multipart/form-data">
<input type='Submit'/>
</form>
POST method in the server.rb file:
post '/list/:name' do
"Hello World"
end
After removing the enctype= attribute, the form is now working as intended.
From what I've learned, the enctype attribute is only used when uploading a file that needs to be submitted with the form. I had it included here because of past issues on different forms where logic errors occurred when it was not included.
Thanks to all for the comments and suggestions.
I have a really simple webform;
<form name="logmeinsupport" action="https://secure.logmeinrescue.com/Customer/Code.aspx" method="post">
<span>Enter your 6-digit PIN code: </span><input type="text" name="Code" /><br />
<input type="submit" value="Connect to technician" />
</form>
On the logmeinrescue side, there will post the error code back into URL:
Like: http://tomtom-uk--tst2.tomtom.com/app/utils/support_login?LogMeInRescueResponse=PINCODE_INVALID
However, our server setup interprets it as a page in web server, therefore, i got 404 error:
404 Page Not Found
The page 'utils/support_login?LogMeInRescueResponse=PINCODE_INVALID.php' was not found.
It is not so easy for our infrastructure team to change it. I am wondering whether I can use Ajax call backs post function to get response. And i think the difficult is about cross server ajax call.
Any examples? Thanks
Cheers,
Qing
The server looks for the file 'utils/support_login?LogMeInRescueResponse=PINCODE_INVALID.php'.
I think you should change your request to:
utils/support_login.php?LogMeInRescueResponse=PINCODE_INVALID
In this way the server will look for support_login.php and if there is indeed a file with this name on your server you will not have this error again.