SWFUpload ASP.Net example site not working? - javascript

http://swfupload.org/node/7/release
The .Net 2.0 sample is not working, has anyone faced the same thing and have been able to make it work?
The solution is compiling and the default page is opening normal in FireFox but when I click on the button nothing happen, and in IE the button is not appearing at all

A few things note with the SWFUploader is that although there is a .Net test project it is a little miss leading and does a lot more than is really required, its great if you want to upload images but dosn't have the progress bar or allow file uploads.
Make sure you get the source code form http://code.google.com/p/swfupload/ not the site, this will fix any issues you have with version 10 / 11 of flash not working.
To get any of the PHP demo working with .Net just make a file called upload.aspx to replace the upload.php with the following code in.
try
{
// Get the data
HttpPostedFile postedfile = Request.Files["Filedata"];
postedfile.SaveAs(Server.MapPath(".\\") + postedfile.FileName);
}
catch
{
// If any kind of error occurs return a 500 Internal Server error
Response.StatusCode = 500;
Response.Write("An error occured");
Response.End();
}
finally
{
Response.End();
}
Change the the default page name to html or .aspx and change the call inside to your new save script.
It will now save the files in the root of the website.

I was having this issue but what fixed it for me was getting the newest version of the swfupload controls. I didnt realize that the stuff you download off google source had the .net stuff in it as well, i was using the out of date controls off the .net page on their website.
if you go to http://code.google.com/p/swfupload/ get the "SWFUpload [version number] Samples.zip" and it has .net stuff in it, which i was able to get working just fine.

i got it, because my Flash version is 10 and SWF is not working with Flash player 10 as its not allowed in Flash player 10 to call a swf file, so the solution for that i putting the object its self on the page and make it as a button to make the user click on the object its self.

Related

C#: .NET based webbrowser doesn't show image

I am new in C# language and I have been trying to automate a website using .NET based webbrowser for ONLY personal use in Visual Studio 2015.
I have done document parsing, used Timer, used DocumentCompleted event properly to wait for the webpage to load completely and then parse the content, tried to make async events to behave like sync events (in order to load HTML content generated by clicking a link in a fully loaded webpage), etc to go through the phases in webpage automation: login -> get trains between stations -> click the Book now link -> go to the next page and fill in the passenger details.
Everything works fine but I am now stuck at the last phase, i.e., "go to the next page and fill in the passenger details" has a captcha image that must be resolved to go to the payment page. Don't get me wrong because I am not trying to get this captcha resolved automatically. The problem here is that I do not see the captch image which turned to be loaded only when this javascript call is invoked $(document).ready.
I thought my project has some buggy code which is stopping to load the captcha and therefore, I created a very basic new project, only added below code and navigated through different phases myself to see if the captcha really loads but unfortunately it would not load.
namespace TestWebBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("https://www.irctc.co.in/eticketing/loginHome.jsf");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
}
}
Please see below. The highlighted part is where I am expecting a captcha.
I must tell you that I am not a web designer and therefore I only understand very basic of how websites work.
I went through several questions on this forum and nothing helped me.
Internet explorer is also using .NET browser from behind but while using IE, I can see the captcha is getting loaded. So, why is this javascript call $(document).ready is not getting invoked in .NET browser. Please see below:
I have later tried to use CefSharp in a fresh new project and I can see the captcha is getting loaded in its chromium based webbrowser. But I have done so much coding with .NET based webbrowser already and therefore I want to stick to the latter at this moment in order to get this resolved.
Is this happening because .NET webbrowser is using some very old IE version configurations?
Please help me to understand.
UPDATE 1: Adding the javascript
<script type="text/javascript">
$(document).ready(function(){
var isJsBlocked=0;
if (typeof(nlpLoadCaptchaAsync) == 'function'){
nlpLoadCaptchaAsync();
}else{
isJsBlocked=1;
}
setTimeout(function(){
var isNLPCaptcha = document.getElementById('nlpIdentifier');
if(isNLPCaptcha == null || isNLPCaptcha=='' ) {
var nlptrack = new Image();
nlptrack.src="http://irctclive.nlpcaptcha.in/temp_redirect_count/irctc_timeout.php?ref=f2c5d744485b0b4251461454db791111&isJsBlocked="+isJsBlocked+"&dynamicParameter="+Date.now();
nlpCaptchaTimeOut(true);
}
}, 5000 );
});
</script>
The answer shared here: Use latest version of Internet Explorer in the webbrowser control solved my issue.
I basically had to change the version of IE version used by my webbrowser control.
Thanks to Matthias herrmann

PDF.js not working when deploying to different Server in IE

I have a local IIS site where i developed some code with PDF.js. There it worked fine to load a specific PDF and read the text contents from it.
Then I copied everything to the a library in a SharePoint Server (thats the only difference, IIS vs SharePoint) and changed all references. The code does not throw any Errors, with debugging level info it just prints
Info: Cannot use postMessage Transfers
to the console. Adding a console.log line into the PDF.js catch block of the promise did not result in any new information. It doesn't even get to the first logging inside the then:
var pdfobj = PDFJS.getDocument(docPath);
pdfobj.then(function (pdf) {
console.log(pdf);
any ideas?
EDITS: Updated from PDF.JS 1.1 to 1.2
There are not many error logs in PDF.js. I accidently hardcoded a wrong URL where even the server is non existent... and no error log, not even the then(...).catch(...) is called?
It is working now in Firefox but not in IE and I cannot see any reason for this. The Info message about Cannot use postMessage Transfers is also only displayed in IE (using IE 11).
It does work now. I am not sure what I did to fix it, but I will update this answer when I know. I think it has something to do with the directory structure of the PDF.js files. Previously I just uploaded all JS files (there were no errors though).
Still there is no exception handling when the PDF does not exist.

Phonegap: Can't get Email Composer to work

I've spent a couple of days trying to implement emailing functionality to my app, but I can't get it to work.
I'm trying to use the plugin (or plugins, as description claims) from here: https://build.phonegap.com/plugins/705
I've added the following code to my XML file:
<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.1" />
Then for testing I created a simple page with a simple code, just to see how it would look. Here is how my JS piece looks:
document.addEventListener('deviceready', function(){
$('#composertest').click(function(){
alert('tapped');
window.plugin.email.isServiceAvailable(function (isAvailable) {
if (!isAvailable){
alert('Service is not available');
}else {
alert('Service is available');
}
});
window.plugin.email.open();
alert('worked(?)');
});
}, false);
The weird thing is that I get both alerts "tapped" and "worked", so if there would be an error, the last alert shouldn't be executed. However I don't get any popup or new window, the plugin seems to do nothing. Alerts about the service don't fire. I've tried to return the type of window.plugin.email in alert and it wrote "Object", so it is not undefined.
I've tried so many things now (including other plugins) that I'm completely lost with clues. Last time I tried to remove JQMobile, but it didn't change anything. Right now the code is very simple and uses as few files as possible and still it doesn't work. I've also tried to make a lot of changes in the code (and also tried the exact example from the docs page) and never got to the point where plugin does anything.
Am I missing something? Is there a working example somewhere?
PS: Phonegap debugger doesn't return any errors, although I don't trust it too much, since it's quite buggy.
If you just want to send a mail within PhoneGap you can just use mailto URI scheme.
Here are some links:
http://css-tricks.com/snippets/html/mailto-links/
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_mailto
This will send an email intent in Android then the user can choose which app to open the mail in.

jQuery is not working in my Facebook Application in Internet Explorer - Access is denied

Just spent about 5 hours sorting out this issue, so I thought sharing how I overcame it would be helpful to someone and save them some time (it seems to be a pretty recent fix - 9 hours ago at the time of posting this question - which I found here).
I am using jQuery version 1.10.1.
Overview
I am building a Facebook tab application. It is a competition entry form where the visitor will enter some information and upload a photo that they took on a recent holiday. I have the form working in all browsers before being embedded into Facebook.
The form is submitted using $.post(). The PHP script that jQuery points to in this process is on the same domain as the form itself.
Before you can submit the form, you must upload a file. The file upload process is built like so:
There is a <div> which acts as a button. Within this div, there is an <input type="file" /> field with its opacity set to 0.
When the invisible file input is clicked, the user selects a file.
When the file is selected, a .change() event is triggered and the <div> will display the text 'Click again to upload'. I did this rather than having the file upload immediately because during my research, I learned that Internet Explorer doesn't like you submitting a form within a .change() handler attached to a file input.
When you click the div again, the form is submitted via .submit(). The form targets a hidden iframe. The file beings uploading, and on completion the iframe triggers a .load() event.
The handler for the load event uses .contents().find("div").html() to get some stringified JSON that I have sent back in the PHP script that manages the file upload. The JSON contains the status of the file upload, and the URL to the processed image if it was successful.
Problem
The application works fine in all browsers except for Internet Explorer when it is embedded into Facebook. Internet Explorer gave the following in the console:
SCRIPT5: Access is denied.
SCRIPT5009: '$' is undefined.
I've researched the second error first and came across all the stuff that I expected to come across and already checked, such as:
The path to the script is wrong.
There may be a htaccess file blocking access to the file.
The script hasn't loaded correctly, clear cache etc and try again.
The possibility that I was trying to use a script that required jQuery before it was loaded.
I have double checked all of these and confirmed they are not the case.
I then moved onto the 'Access is denied' error and all the material I am coming across points to an issue regarding cross-domain requests using AJAX. There are also some articles that mention file uploading specifically, but nothing that was 100% relevant to me in this case.
Question
Why am I getting these errors in Internet Explorer when I try to use jQuery in an page that is embedded into Facebook? I got them even when I removed every other script on the page (except for jQuery), so I assume it is triggered by the presence of the hidden iframe that I have on the page to deal with image uploads.
First, I removed every other script on the page, at which point I only received the following error (obviously because I wasn't trying to make use of $ anymore):
SCRIPT5: Access is denied.
After trying about a dozen things (and combinations of those) that I found around the internet, I decided to use the non-minified version of jQuery so that I could more accurately determine the line that was causing my issue. After uploading that and taking another look in the console, I was pointed to line 1513, which looked like this:
if ( parent && parent.frameElement ) {
Above this line was a comment which made note of the issue that I was experiencing:
// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
I Googled jQuery #13936 and came across this page, which suggested that I swap out the above line with:
if ( parent && parent.attachEvent && parent !== parent.top ) {
After making this change, I was glad to find the issue resolved and my form working as expected. I double checked the other browsers again and can confirm that they still work as expected as well.
Solved
This is a legit jQuery 1.10.1 bug: http://bugs.jquery.com/ticket/13980 .
Using jQuery 1.10.0, or 1.10.2 the error no longer occurs.

Why does Cordova 2.7.0 JS seemingly no longer work on remote pages?

Background
I'm attempting to upgrade an iOS app built on Cordova 2.0 to version 2.7.
It's basically a welcome screen that points to a remote search engine (please withhold comments about app validity and likely approval, as we're past that), and we were using the ChildBrowser plugin to enable opening links in a sub browser so as not to trap the user in the Cordova webview.
Cordova 2.7 has a feature called InAppBrowser I am hoping to use instead of ChildBrowser. InAppBrowser does essentially the same thing, aside from missing a button to open in Safari.
Problem
The existing app's remote webpages include the Cordova JS (as well as that for the ChildBrowser plugin) and it works fine for opening links in the sub browser.
My test Cordova 2.7 app doesn't seem to load the Cordova JS correctly when it's being loaded from a remote web page.
I tried using this exact same HTML on the embedded start page and a remote start page:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://mydomain.com/mobile/cordova-2.7.0.js"></script>
</head>
<body>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("Ready!!");
}
</script>
</body>
</html>
To test this as the embedded start page, I put this line in config.xml:
<content src="index.html" />
When I run the app, I promptly get the "Ready!" alert.
To test this as the remote start page (I'm aiming to link to the remote page in the final app, I am just using it as the start page for testing. The result is the same if I link from the embedded page.), I put this line in config.xml:
<content src="http://mydomain.com/mobile/index.php" />
When I run the app, I just get the blank screen and no alert.
Further, in cordova-2.7.0.js L. 6255, I changed
console.log('deviceready has not fired after 5 seconds.');
to
alert('deviceready has not fired after 5 seconds.');
With that change, running the app using the remote start page causes the blank page, and then after five seconds, I get the alert "deviceready has not fired after 5 seconds.". So this tells me Cordova JS is not starting correctly. Needless to say, I can't get InAppBrowser to launch links in the sub browser on the remote site, but I can get it working just fine on the embedded start page.
Anyone have any ideas of where to go from here? This is a pretty simplistic example, so I'm assuming this is a Cordova settings problem or a change in the functionality. I appreciate any thoughts, thanks!
Yes, something broke in 2.7 - related to our cordova-cli work. See: https://issues.apache.org/jira/browse/CB-3029
The fix is to add an empty file called "cordova_plugins.json" in your root folder.
I had a similar problem relating to upgrading to Cordova 2.7. However my problem was all my console.logs stopped firing when running the app. I couldn't figure out why for the life of me this was happening. I thought it was because I upgraded jquery.mobile. That wasn't it. I then thought it was an .htaccess issue, that wasn't it either. It turns out, it was Cordova 2.7 that was causing this problem.
I did try adding the .json file on my server, that did not fix the issue.
The fix was going into the 2.7 source and commenting out the following code:
/*comment out this as it is breaking console.logs
var xhr = new context.XMLHttpRequest();
xhr.onload = function() {
// If the response is a JSON string which composes an array, call handlePluginsObject.
// If the request fails, or the response is not a JSON array, just call finishPluginLoading.
var obj = this.responseText && JSON.parse(this.responseText);
if (obj && obj instanceof Array && obj.length > 0) {
handlePluginsObject(obj);
} else {
finishPluginLoading();
}
};
xhr.onerror = function() {
finishPluginLoading();
};
xhr.open('GET', 'cordova_plugins.json', true); // Async
xhr.send();
*/
Replace entire block with a call to the following function:
finishPluginLoading();
My logs are now working again. Only took me 3 days scratching my head.
Hope this helps someone with a similar problem.
If you embed Cordova in the external web page, there will be no way to open the InAppBrowser from within your hybrid app, so Cordova will not be able to load. This is because the InAppBrowser requires Cordova to be fully loaded and initialized before it can be used to fetch a remote page. You need to use your HTML page that you have, with the <script type="text/javascript" src="http://mydomain.com/mobile/cordova-2.7.0.js"></script> as the main entry point for your app. Then you can use the InAppBrowser to open up your remote page. (You could probably do this in the onDeviceReady(), not sure if it would "flash" the page first though.) I don't think the remote page should have any Cordova code in it at all. I'm not sure if it would be possible to even interact with Cordova from the remote page due to the Same Origin Policy (probably you could use features of the InAppBrowser to inject "bridge" code though to get around this.)
As Shazron mentioned the problem is the issue with the file"cordova_plugins.json".
To solve the problem not changing the code you can create the "cordova_plugins.json" file in the root folder and insert a content between quotation marks inside this file.
Mine for example has the following content:
"Just a dummy file required since Cordova 2.6.0"
create a file cordova_plugins.json that contains {}. then go to cordova-2.7.0.js and comment this line require('cordova/channel').onNativeReady.fire(); then when development done, add it back
Like me if you are using Cordova 5.1.1 and want to access native functionality after redirect then copy cordova.js, cordova_plugins.js and plugins folder which is at \platforms\platform_name\assets\www\ and put them on server, finally reference cordova.js inside your html. After every plugin add make sure to update these files and folder.

Categories