|
You might struggle to get that working with older browsers, but most modern browsers[^] can do that on the client-side. (The notable exception being IE10 or earlier.)
There are various pre-built plugins to do this - for example:
Or you could roll-your-own - this StackOverflow answer[^] seems like a good place to start.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The stackflow answer is great and I can see it working exactly as I would like here
Edit fiddle - JSFiddle[^]
but I cannot get it to work in Visual Studio with my own project?
Below is what I have, I feel like this is a pretty dumb question, but I cannot figure out what is wrong?
<pre><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Updater.aspx.cs" Inherits="Updater.Updater" %>
<script language=javascript>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function () {
readURL(this);
});
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Exchange Avatar</title>
</head>
<body>
<form id="form1" runat="server">
<br /><br /><br />
<input type='file' id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
</body>
</html>
|
|
|
|
|
The <script> block needs to be within the document - just before the closing </body> tag would be a good place.
You also need to add a reference to jQuery, since you're using it to wire up the event handler. The jQuery CDN[^] is probably the simplest way to add this.
There's no need for the xmlns declaration on the <html> tag, since you're using HTML5, not XHTML. You also don't need the language attribute on the <script> tag, since Javascript is the only supported language.
<!DOCTYPE html>
<html>
<head runat="server">
<title>Exchange Avatar</title>
</head>
<body>
<form id="form1" runat="server">
<br /><br /><br />
<input type="file" id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
<!--
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<!--
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$("#blah").attr("src", e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function () {
readURL(this);
});
</script>
</body>
</html>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the reply and the code, does this preview the image on your machine? For some reason it does not on my machine and when I change the form to add an onchange event it tells me that "imagepreview is undefined" ?
<form id="form1" runat="server">
<br /><br /><br />
<input type="file" id="imgInp" onchange="imagepreview(imgInp);" />
<img id="blah" src="#" alt="your image" />
</form>
I even have this function as well, inside of the script tags
function imagepreview(input) {
if (input.file && input.files[0] {
var fildr = new FileReader();
fildr.onload = function(e) {
$('#imgprw').attr('src', e.target.result);
}
fildr.readAsDataURL(input.files[0]);
|
|
|
|
|
The code I posted works fine on my machine. Which browser are you using?
turbosupramk3 wrote: if (input.file && input.files[0] {
You're missing a closing ) on that line.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I thought I had IE11, but it is actually IE9 which I'm going to guess is my problem?
I also tried Chrome (v 52.xx) and Firefox (v 28) and neither of those worked either?
modified 2-Jun-16 10:15am.
|
|
|
|
|
IE10 and earlier doesn't support the APIs needed to preview images. Firefox and Chrome should be fine, though.
Check the developer console to see if you're getting any errors.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm only getting 2 warning messages
Warning 2 Validation (HTML5): Attribute 'crossorigin' is not a valid attribute of element 'script'. c:\users\xxxxx\documents\visual studio 2012\Projects\Updater\Updater\Updater.aspx 122 128
Warning 1 Validation (HTML5): Attribute 'integrity' is not a valid attribute of element 'script'. c:\users\xxxxx\documents\visual studio 2012\Projects\Updater\Updater\Updater.aspx 122 64
|
|
|
|
|
|
I think it is something where the entire image path has to be in the code.
Thank you for the help
|
|
|
|
|
I have a IP camera. I need to capture images using vb6 or vb dot net.pls help
|
|
|
|
|
Have some Google Foo[^]. The second result seems to be exactly what you are looking for.
You need to learn to do some basic research!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Greetings experts,
I am trying to show display reset password screen if data reader fetches records from the database matching the current user's information.
However, no matter what I try, I always get the following message:
Reset password link has expired.It was for one time use only
Any idea what I need to change in the code below?
Thanks in advance
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim dr As OleDbDataReader
Try
'Here we will check from the passed querystring that if the email id/username and generated unique code is same then the panel for resetting password will be visible otherwise not
cmd = New OleDbCommand("select UserName,myemail,[UniqueCode] from tblusers where [UniqueCode]=@uniqueCode and (myEmail=@emailid or UserName=@username)", con)
cmd.Parameters.AddWithValue("@uniqueCode", Convert.ToString(Request.QueryString("uCode")))
cmd.Parameters.AddWithValue("@emailid", Convert.ToString(Request.QueryString("myEmail")))
cmd.Parameters.AddWithValue("@username", Convert.ToString(Request.QueryString("uName")))
If con.State = ConnectionState.Closed Then
con.Open()
End If
dr = cmd.ExecuteReader()
If dr.HasRows Then
ResetPwdPanel.Visible = True
Else
ResetPwdPanel.Visible = False
lblExpired.Text = "Reset password link has expired.It was for one time use only"
Return
End If
dr.Close()
dr.Dispose()
Catch ex As Exception
lblStatus.Text = "Error Occured: " & ex.Message.ToString()
Finally
cmd.Dispose()
con.Close()
End Try
End If
End Sub
|
|
|
|
|
Your select statement is returning no rows, why that is only you can know. We don't know your inputs or what data is in your database.
|
|
|
|
|
Excuse me for being a bit snarky but for some reason you tend to present yourself as extremely knowledgeable and the opposite seems to be the case.
YOU do this ALL the darn time.
I don't understand what you mean by you don't know my inputs.
If I know why my SELECT statement is returning no rows, do you think I would be asking for help?
The code I posted clearly shows input params and I have verified there is data matching the input values I am using for testing.
Obviously, there is something I am missing which is why I came here to ask someone, anyone interested in helping rather than someone making some silly comments.
|
|
|
|
|
F-ES Sitecore explained that no one here has any idea what is in your database, or what the values of the parameters in your SELECT statement are. So how exactly do you think anyone here could guess why it returns no rows? Use your debugger to examine exavctly what the parameter values are and see whether they match a record in the database.
|
|
|
|
|
samflex wrote: I don't understand what you mean by you don't know my inputs.
Inputs are what go in to your system so in your case the inputs are Request.QueryString("uCode"), Request.QueryString("myMail") and Request.QueryString("uName"). We don't know what values you are using as we don't know what the url you are using to access your page is. You could have helped by saying in your question, "This is the url I use..." and that would have given us some idea. It probably wouldn't help though.
Secondly we don't know what is in your database, the most likely issues is that there just isn't a row that satisfies your query. As we don't know your inputs nor your data how can we possibly say?
Asking questions is a skill, so what you should do is post the url you are using and an example of the row of data in your database that you think satisfies your query. The issue might be white spaces, or I see you are using an email address so maybe you are not properly encoding the "@"? As I said, how can we know as you didn't supply enough info? Even with the info I just said you should provide, maybe you are mistaken about your connection string and are connecting to a different database than the one you think you are? If you think that's stupid then I've seen it many many times.
When it comes to questions like this, the best solution by far is for you to learn how to debug your code. Use the debugger to examine the inputs and the query, use SQL Profiler to see exactly what query is being executed, and use SQL Management Studio to run that query and\or examine the data in your database to see if you can work out why nothing is being returned. What I am basically saying is that your code is only half of the issue, the data is the other, and there doesn't seem anything wrong with your code so the issue is with the data which we can't see.
|
|
|
|
|
samflex wrote: YOU do this ALL the darn time. Interesting. So do I and several others apparently. Hmmmm.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have been tasked with moving an ASP .NET production servers web application from a 2008 Windows server to a 2012 Windows server. I do not have the application's source code and only have the deployed to IIS application files. Can I do this and if so does anyone know of an artical to instruct me on doing so?
|
|
|
|
|
This is very, very, easy to do, assuming there are no hiccups.
Copy the files from the one server to the other server. Then in the new server, setup a website in IIS and configure it the same way the 2008 server was. Done.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
And once you've done that quit your job and work for someone that has the source code for their production websites
|
|
|
|
|
Perhaps. I could be wrong but I read this as the OP is a network admin type of person and has to move a website. Therefore, the source code has nothing to do with the question.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi All,
I want to print my .aspx page with data while its running inside a loop.
For E.g My loop is till dt.rows.count and in every loop I Want to print the page with data.
If count is 7 than 7 pages need to be printed.
|
|
|
|
|
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
This is more a CSS issue. You can't print to the client's machine via asp.net code, and your asp.net code runs in its entirety before sending anything to the client so you can't "loop" the way you are intending.
Instead send all 7 pages to the client with the relevant css that designates where the page breaks are and the client will need to print from their browser (no you can't do that automatically either, neither can you force them to print) and the documents will be on their own pages. Google for css page breaks or for print style css in general.
|
|
|
|