Giter Club home page Giter Club logo

Comments (3)

twilson63 avatar twilson63 commented on June 27, 2024

Since its actually doing a form POST, I think it would be pretty hard to
set custom headers, but you can do one of the following:

If you don't have to support ie browsers less than 10 then you should use
FormData api, it allows you to use xhr2 to submit files via ajax.

https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/FormData

If you do have to worry about supporting IE 8 and IE 9, then you could
submit everything but your files via an ajax post and then submit just your
files via the iframe post, you should be able to execute both so that the
user only has to click once. Let me know if this answers your question.

Thanks for the feedback

Tom

On Sat, Apr 20, 2013 at 4:01 PM, Spiros Kabasakalis <
[email protected]> wrote:

Hi,great directive!.I am working on an angular app featuring basic REST
CRUD operations.Problem is,my create action features an image upload(along
with other text fields),and the REST API authenticates the requests with
custom headers.With ajax this is no problem,you can set custom headers on
the client,but with iframe technique that your directive uses-this is a
problem.Do you have any idea on how to solve this?Thanks in advance!


Reply to this email directly or view it on GitHubhttps://github.com//issues/28
.

Tom Wilson
Jack Russell Software Company Division of CareKinesis
494 Wando Park Blvd
Mount Pleasant, SC 29464
Phone: 843-881-2171
Email: [email protected]
Web: http://www.jackhq.com
Calendar:
http://www.google.com/calendar/embed?src=tom%40jackrussellsoftware.com&ctz=America/New_Yorkhttp://www.jackhq.com/calendar

This e-mail may contain information that is confidential, privileged or
otherwise protected from disclosure by the Health Insurance Portability and
Accountability Act (HIPAA) and other state and federal laws. This
information is intended only for the individual names above. Any review,
use disclosure or dissemination of this material is strictly prohibited.
If you receive this information in error, please notify CareKinesis
immediately at 888-974-2763 and delete the original at once.

from ngupload.

kabasakalis avatar kabasakalis commented on June 27, 2024

Thanks Tom,I used FormData,I could care less for old IEs,this is a demo for developers anyway (Angular with PHP backend -Yii framework).I ended up using this

    $scope.create=function(){
       var  form = $('#cform');
        var formdata = false;
            if (window.FormData){
                formdata = new FormData(form[0]);
            }
      var   method='POST';
     var formAction ="http://yii.gr/lab/api/resttest";
        $http( {
            data:formdata,
            url:formAction,
            method:method,
          headers: { 'Content-Type': false,                                     
                         'X_REST_PASSWORD':'PASSWORD',
                         'X_REST_USERNAME':'[email protected]' },
         transformRequest: function(data) { return data; }
        }).success(function(response, status, headers, config) {
            // this callback will be called asynchronously
            // when the response is available
                  //stuff to do with response
          }).
          error(function(data, status, headers, config) {
 //stuff to do on error
          });

    };

from ngupload.

twilson63 avatar twilson63 commented on June 27, 2024

Awesome!!

Thx

Tom

Sent from my iPhone

On Apr 27, 2013, at 3:35 PM, Spiros Kabasakalis [email protected]
wrote:

Thanks Tom,I used FormData,I could care less for old IEs,this is a demo for
developers anyway (Angular with PHP backend -Yii framework).I ended up
using this

$scope.create=function(){
   var  form = $('#cform');
    var formdata = false;
        if (window.FormData){
            formdata = new FormData(form[0]);
        }
  var   method='POST';
 var formAction ="http://yii.gr/lab/api/resttest";
    $http( {
        data:formdata,
        url:formAction,
        method:method,
      headers: { 'Content-Type': false,
                     'X_REST_PASSWORD':'PASSWORD',
                     'X_REST_USERNAME':'[email protected]' },
     transformRequest: function(data) { return data; }
    }).success(function(response, status, headers, config) {
        // this callback will be called asynchronously
        // when the response is available
              //stuff to do with response
      }).
      error(function(data, status, headers, config) {

//stuff to do on error
});

};


Reply to this email directly or view it on
GitHubhttps://github.com//issues/28#issuecomment-17121944
.

from ngupload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.