1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    3
    Vote Rating
    0
    wood is on a distinguished road

      0  

    Default JavaScript help needed

    JavaScript help needed


    i need to upload files to the server without the page being reloaded. once the file has been upload the user needs to be notified that it has been uploaded.

    i need the image to be assigned to a variable name and then stored on the server for use on other pages. this is the code i have used to send the image to the upload page

    <script language="javascript">
    function submitForm()
    {
    var http = null;
    if(window.XMLHttpRequest)
    http = new XMLHttpRequest();
    else if (window.ActiveXObject)
    http = new ActiveXObject(

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You can't upload files using XMLHttpRequest (that would be a security risk).

    The only way to upload files without reloading the page is to post the form to a hidden IFRAME.

    ps. Ext has support for this build into Ext.Ajax.request().

  3. #3
    Ext User
    Join Date
    Mar 2008
    Posts
    3
    Vote Rating
    0
    wood is on a distinguished road

      0  

    Default


    can the Ext.Ajax.request be used as a stand alone or do i need the ext.lib to use it.

    I have looked at using this but i dont really no how it works i got this code but it did not seem to do anything.

    Ext.Ajax.request({
    form: 'file-form',
    url: '/myUpload.do', // Optional if the form has the correct action attribute
    params: { // Optional params that are temporarily added as hidden
    type: 'jpg'
    caption: 'A picture'
    },
    isUpload: true // Optional if the form has enctype="multipart/form-data"
    success: function() {
    alert('File uploaded');
    },
    failure: {
    alert('File could not be uploaded');
    }
    });

    as i have not used this code before i am unsure as to where it will go and i placed it after my submit button which the code for it looks like this

    Image 1<br />
    <form name="newad" enctype="multipart/form-data" action="" method="post">
    <input type="file" id="file-form" ><input name="Submit" type="submit" value="Upload image">

    it might be a bit of a stupid question but i am trying to teach myself how to do this.

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You could look at the code in Ext.Connection.doFormUpload

    or you could google...

  5. #5
    Ext User
    Join Date
    Mar 2008
    Posts
    3
    Vote Rating
    0
    wood is on a distinguished road

      0  

    Default file upload

    file upload


    i have now went down the road of using iframes to upload the image. my page still reloads as i am still using the submit button. could i get round this by using javascript to submit the from the iframe. i would have to write my own function to handle the passing of the file to the upload.php page.

    is it possible to do it in this way?

Thread Participants: 1