Click here to Skip to main content
15,307,334 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: [Vanilla Javascript Newbie] How to access a function of a function from a part of code oustide this function Pin
Richard MacCutchan8-Nov-20 21:58
mveRichard MacCutchan8-Nov-20 21:58 
AnswerRe: [Vanilla Javascript Newbie] How to access a function of a function from a part of code oustide this function Pin
Richard Deeming9-Nov-20 22:07
mveRichard Deeming9-Nov-20 22:07 
QuestionGet image extension Pin
Valentinor4-Nov-20 3:10
MemberValentinor4-Nov-20 3:10 
AnswerRe: Get image extension Pin
Blanksy8-Nov-20 11:12
MemberBlanksy8-Nov-20 11:12 
GeneralRe: Get image extension Pin
Valentinor8-Nov-20 19:33
MemberValentinor8-Nov-20 19:33 
GeneralRe: Get image extension Pin
Richard Deeming8-Nov-20 21:53
mveRichard Deeming8-Nov-20 21:53 
GeneralRe: Get image extension Pin
Valentinor9-Nov-20 5:43
MemberValentinor9-Nov-20 5:43 
GeneralRe: Get image extension Pin
Richard Deeming9-Nov-20 5:58
mveRichard Deeming9-Nov-20 5:58 
You'd have to write something on the server - eg: ASP.NET, PHP, etc. Basically, any server-side language that can make a HEAD request and read the headers from the response.

For example, in C#:
C#
public static async Task<string> GetContentType(HttpClient client, string url)
{
    if (string.IsNullOrEmpty(url)) throw new ArgumentNullException(nameof(url));
    if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) throw new ArgumentException("Invalid URL", nameof(url));
    
    using (var request = new HttpRequestMessage(HttpMethod.Head, uri))
    using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
    {
        response.EnsureSuccessStatusCode();
        return response.Content.Headers.ContentType.MediaType;
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Get image extension Pin
Valentinor9-Nov-20 10:31
MemberValentinor9-Nov-20 10:31 
GeneralRe: Get image extension Pin
Richard Deeming9-Nov-20 21:36
mveRichard Deeming9-Nov-20 21:36 
GeneralRe: Get image extension Pin
Valentinor10-Nov-20 4:10
MemberValentinor10-Nov-20 4:10 
Questionfunction with OR Pin
Member 1497891029-Oct-20 9:30
MemberMember 1497891029-Oct-20 9:30 
AnswerRe: function with OR Pin
Richard MacCutchan29-Oct-20 10:41
mveRichard MacCutchan29-Oct-20 10:41 
SuggestionJSMAN - JavaScript Map alternative notation Pin
Member 1497706227-Oct-20 17:35
MemberMember 1497706227-Oct-20 17:35 
GeneralRe: JSMAN - JavaScript Map alternative notation Pin
Sandeep Mewara27-Oct-20 19:34
mveSandeep Mewara27-Oct-20 19:34 
Questionfind low distance from two matrices Pin
costy3527-Oct-20 6:57
Membercosty3527-Oct-20 6:57 
GeneralRe: find low distance from two matrices Pin
Richard MacCutchan27-Oct-20 7:14
mveRichard MacCutchan27-Oct-20 7:14 
GeneralRe: find low distance from two matrices Pin
costy3527-Oct-20 11:18
Membercosty3527-Oct-20 11:18 
GeneralRe: find low distance from two matrices Pin
Richard MacCutchan27-Oct-20 21:49
mveRichard MacCutchan27-Oct-20 21:49 
QuestionConverting image file format Pin
Valentinor26-Oct-20 23:40
MemberValentinor26-Oct-20 23:40 
QuestionGoogle Map API & JavaScript Issue (Snowload Calculator) Working Model for easier troubleshooting Pin
Member 1497471825-Oct-20 4:31
MemberMember 1497471825-Oct-20 4:31 
QuestionXML NodeList Java object showing null in Nashorn Javascript Pin
shampoo7224-Oct-20 9:40
Membershampoo7224-Oct-20 9:40 
AnswerRe: XML NodeList Java object showing null in Nashorn Javascript Pin
Richard MacCutchan24-Oct-20 21:59
mveRichard MacCutchan24-Oct-20 21:59 
GeneralRe: XML NodeList Java object showing null in Nashorn Javascript Pin
shampoo7225-Oct-20 6:04
Membershampoo7225-Oct-20 6:04 
GeneralRe: XML NodeList Java object showing null in Nashorn Javascript Pin
Richard MacCutchan25-Oct-20 6:14
mveRichard MacCutchan25-Oct-20 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.