Posts

Showing posts with the label php

Consume ASP.NET Web API Using PHP and JQuery

Image
Background Whether it is shortage of required skills, platform unavailability or even laziness, anything could make you want to cut some corners in development. And please get me right, by cutting corners I do not mean writing code that is cumbersome and difficult to maintain or leaving out important possible outcomes to favour low turnaround times. There's this popular quote that drives this best practice home: Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. Issue We had this project I was working on with a team. Its kind of like a payment aggregator, functioning in similar manner as your regular payment gateways like Paypal, UPL, Interswitch. You can find the project here ( a1pay.net ). I was the front-end guy, which meant that I was basically responsible for presentation. However, in a twist of events, I was also saddled with handling the POST request from our 3rd party payment gateways, consume an alrea...

Specify Name for Uploaded File At Upload Time Using DropZone.js

Image
Background: After surmounting my last challenge with dropzone.js and was able to upload my files. I was immediately faced with another one. The dropzone.js implementation apparently doesn't include any method for computing a value to send to the server while the file is being uploaded. What this means is that any headers or form data used to initialize the dropzone will be used repeatedly each time a file is uploaded. Issue: This meant that, for instance if I didn't want to upload a file using its name from the client, I may not be able to specify another name for the file as it is being uploaded. And that was exactly what I was faced with. Each time I created another record and uploaded a corresponding file with the dropzone, the file would overwrite my previous files, because I was apparently sending the same custom filename to the server to save my files with. My dropzone initialization code looked like this var mydropzone = $(targetelement).dropzone({     ...

Post Data to ASP.NET Page From PHP or Javascript

Image
Background: For most PHP developers, the technique of posting data from one page to a different page is not a difficult thing. In fact, in PHP development, this technique is learnt by beginners. In ASP.Net however, it doesn't work the same way. The ASP.Net platform is designed to implicitly post data to itself and developers need not manually trap posted data themselves. Issue: This simplistic development approach implemented by ASP.Net poses a problem where one needs to for one reason or the other, post to the ASP.Net page from another ASP.Net page, a PHP page, from JavaScript or even Python, ruby, and any other server side platform you can imagine. In my own case, I was using dropzone.js to implement drag-and-drop file upload for an application. I would have to post to a server side platform using JavaScript. For some reasons, I didn't want to use PHP, even though PHP would work seamlessly. The platform available for me was ASP.Net, but remember; ASP.Net doesn't...