Home > javascript > Why can't we upload a file using this method which uses Ajax

Why can't we upload a file using this method which uses Ajax

May 25Hits:1

I'm trying to load a 3D model into Three.js with JSONLoader, and that 3D model is in the same directory as the entire website.

I'm getting the "Cross origin requests are only supported for HTTP." error, but I don't know what's causing it nor how to fix it.


My crystal ball says that you are loading the model using either file:// or C:/, which stays true to the error message as they are not http://

So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp and change the url to http://example.com/path/to/model

Just to be more explicit than above - so yes you cannot point your browser directly at file://some/path/some.html so instead once you have python installed cd into the dir where your some.html file(s) lives then issue :

 python -m SimpleHTTPServer

which will spin up a web server hosting entire dir listing which you reference from URL :


this is built into any python install (batteries are included). For python3 use this :

python3 -m http.server

Alternatively, if you demand a more responsive setup and already use nodejs and npm just issue

npm install -g http-server

then, as above, cd into dir containing your some.html and issue :

http-server -c-1

which spins up a nodejs httpd which does a dir listing of your static files visible from :


In Chrome you can use this flag:


Read more here.

Ran in to this today.

I wrote some code that looked like this:

app.controller('ctrlr', function($scope, $http){
    $http.get('localhost:3000').success(function(data) {
        $scope.stuff = data;

...but it should've looked like this:

app.controller('ctrlr', function($scope, $http){
    $http.get('http://localhost:3000').success(function(data) {
        $scope.stuff = data;

The only difference was the lack of http:// in the second snippet of code.

Just wanted to put that out there in case there are others with a similar issue.

For those on Windows without Python or Node.js, there is still a lightweight solution: Mongoose.

All you do is drag the executable to wherever the root of the server should be, and run it. An icon will appear in the taskbar and it'll navigate to the server in the default browser.

Also, Z-WAMP is a 100% portable WAMP that runs in a single folder, it's awesome. That's an option if you need a quick PHP and MySQL server.

I was getting this exact error when loading an HTML file on the browser that was using a json file from the local directory. In my case, I was able to solve this by creating a simple node server that allowed to server static content. I left the code for this at this other answer.

er. I just found some official words "Attempting to load unbuilt, remote AMD modules that use the dojo/text plugin will fail due to cross-origin security restrictions. (Built versions of AMD modules are unaffected because the calls to dojo/text are eliminated by the build system.)" https://dojotoolkit.org/documentation/tutorials/1.10/cdn/

Related Articles

  • Why can't we upload a file using this method which uses Ajax May 25

    I'm trying to load a 3D model into Three.js with JSONLoader, and that 3D model is in the same directory as the entire website. I'm getting the "Cross origin requests are only supported for HTTP." error, but I don't know what's causing it nor how

  • Uploading a file to a varbinary on SQL ServerJuly 7

    Is there any way to upload a file to a varbinary on SQL Server without writting a program to do it? --------------Solutions------------- Looks like this might work for you... http://www.databasejournal.com/features/mssql/article.php/3632741/Upload-mu

  • How to upload a file from the command line with FTP or SSH?December 12

    I have never done this before and I am creating a bash shell script to do this for me. I will also be connecting via ssh to do some things (which I already know how to do). So maybe there is a way to upload files via ssh so I can do it all in one con

  • 100% CPU usage while uploading large filesDecember 19

    please, help me to resolve the issue. I have an images processing website on the dedicated server. After moving to more powerful server I met strange problems. First server configuration was: Core 2 Quad 6600 4G DDR2 RAM 2x500GB SATA + Hardware Raid0

  • upload excel file from client machine to server in java March 11

    How can I upload files to server using JSP/Servlet? I tried this: <form action="upload" method="post"> <input type="text" name="description" /> <input type="file" name="file" />

  • Upload a file using scp only if the file was updated/modified?March 11

    pscp is a very handful tool if you want to upload files to another server using SSH. The only problem is that it is not able to detect if the destination file is already updated (based on datetime). I don't want to upload the file again if the file w

  • Why Netbeans 6.8 remote project (php) uploads all files by defaultMarch 19

    Hi I wanted to know if there's some option for disabling Netbeans to upload all files of a recently imported remote (php) project. I always check "Upload files on run", in the project configuration. But when I click on run Netbeans selects all f

  • Upload Multiple Files - random error April 6

    In the Upload Document dialog box, when I click Upload Multiple Files..., I get Microsoft .NET Framework error dialog box. When I click on Details button, it gives the following error message: System.ArgumentException: Value does not fall within the

  • Encrypt uploaded pdf files with mcrypt and phpMay 20

    I'm currently set up with a CentOS box that utilizes mcrypt to encrypt/decrypt data to/from the database. In my haste, I forgot that I also need a solution to encrypt files (primarily pdf, with a xls and txt file here and there). Is there a way to ut

  • Apache2 memory usage when uploading large filesJune 2

    I am running apache2.2.12 along with PHP 5.2.10. PHP is configured to run as a separate process through fcgid. The problem is that when users upload a file, size of the apache process swells by almost the same amount. So if somebody tries to upload a

  • How to Upload Large Files in PHPAugust 17

    Uploading a file from a web form in PHP is easy. The online manual provides a Handling File Uploads section, and there are several articles on sitepoint.com, including How To Handle File Uploads With PHP by Kevin Yank. One of the most popular uses is

  • Uploaded Site Files not Displaying After Creating Virtual Host on FreeBSDAugust 22

    Good Morning, Newbie Alert!! :) I created a virtual host on my FreeBSD server and have the domain name pointing to the server. I uploaded site files to /home/servername/www/virtualhostname. I see there are alos files in /usr/local/apache2/htdocs. The

  • Quickest Way Besides FTP to Upload WordPress Files to a Web Server?September 6

    Assume I have SSH from a shared/managed-VPS hosting, and FTP access, but no fantastico. Thanks. --------------Solutions------------- Yes. There is a script called easywp.php You upload it to your server and run it. it will install wordpress for you (

  • How to automatically upload changed files over FTP

    How to automatically upload changed files over FTPSeptember 14

    I have an IDE PyCharm for editing a Django application I am working on now. It has no FTP access and I work with a local copy of my application. Then I have to upload changed files to my production server over FTP. So, is that possible to automatical

  • FTP issue uploading a file that does not appear liveNovember 12

    I am successfully uploading my files via FTP to my server. My client is showing it is there. When I try an access the URL i get a 404. Not sure why. I entered in the correct URL (my client also offers the option to open the file) --------------Soluti

  • connections are abort while uploading big filesNovember 15

    I have the same web application written in PHP running on 2 different machines. On one of the machines, connections are often abort while uploading big files via HTTP; while on the other machine, the application runs perfectly. Both machines run on C

  • Upload multi files controls?December 27

    I have a web part which contains FileUpload asp.net control , i want to replace FileUpload asp.net control with Upload Multi Files Sharepoint control. Is there a way to reference this control in my project? Best regards --------------Solutions-------

  • Problem uploading a file to Ubuntu One using the web interfaceDecember 27

    When I try to upload a file via the Ubuntu One web interface, the server constantly goes down, and it's impossible upload a tiny file. Any suggestion as to what is happening? --------------Solutions------------- We had some server problems yesterday,

  • Problems when uploading large files to Amazon S3January 15

    I tried to use Amazon SDK (Java) sample code called S3TransferProgressSample.java to upload large files to Amazon s3 storage (also posted here http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?HLuploadFileJava.html). But when I am tryi

  • Are there any security considerations if users are allowed to upload flash filesJanuary 27

    Lets say I have a website where users are allowed to upload files which will be displayed publicly as a portfolio gallery. For example, users might upload screenshots of a website they designed, or a MS Word document of some PR example text, or a PDF

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.695 s.