Upload file is not working using AngularJS on lighttpd server - angularjs

In my current project we are using lighttpd server. Here I am trying to upload the file. I am getting two Response Headers, first is with 301 Status code (Moved Permanently) and second is with 200 (OK).
But when I am checking in the folder I am not able to find any file (I mean no file uploaded).
I have tried both way to upload file as given links below:
http://jsfiddle.net/danialfarid/0mz6ff9o/135/
ngFileUpload
https://jsfiddle.net/JeJenny/ZG9re/
In both way I am getting the same response.
So here I have some sort of questions:
1) Is file upload is possible using AngularJS only? (No Server Side Script)
2) If possible, Is there any config problem with lighttpd?
Thanks !
Need Help...

The server side (or any web server) must be configured to handle POST and PUT requests. CGI, FastCGI, SCGI scripts can be written, or you can proxy to another backend. For simple file uploads, lighttpd also provides mod_webdav which you can configure (and protect with mod_auth) to allow you to upload files without having to write any server-side code.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModWebdav

Related

Extracting zipped images from utf-8 encoded reponse of a rest api call and displaying those images to user in react without downloading

I have a zipped file containing images which I am sending as response to a python REST API call. I want to create a rest application which consumes the python rest api in this manner: The response's content should be extracted without downloading (in browser side) and all the images should be displayed to the user. Is this possible? If yes, could you please help me in the implementation? I am unable to find help anywhere.
I think what you are trying to do is have a backend server (python) where zip files of images are hosted. You need to create an application (that could be in react) that
Send HTTP calls to the server get those .zip files.
Unzip them. How to unzip file on javascript
Display the images to the user. https://medium.com/better-programming/how-to-display-images-in-react-dfe22a66d5e7
I'm not sure what utf-8 has to do with this, but this is possible. A quick google gave me the results above.

How to create folders and images using AngularJS

I have an AngularJS app that, upon requested to upload an image, creates a folder inside the file system (CentOS) and then puts that image there, telling the user everything went OK or not.
Is this possible? All I've found is ways to download the file.
Thanks.
It is better to delegate this task to a service on the server, since it is file that is uploading to a server. I put simple rest service to file upload this file to the server.

How to "require" a .yml file?

I'm a beginner just trying to get the hang of elasticsearch with angular and have installed elasticsearch with the browserbuild here: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html
I was able to get elasticsearch loaded into angular as a module and was following along with this sample repo: https://github.com/spalger/elasticsearch-angular-example/blob/master/README.md
When I tried to run the cluster.state call, I received the following error: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
According to the sample repo, I need to configure the elasticsearch.yml file in order to allow CORS. I couldn't seem to find this file so I created my own but how do I now get my js files to "require" or "read" from it?
This is the configuration file for elasticsearch. It does not belong to the client.
Read about elasticsearch installation in their site and setup your development elasticsearch server to work against.
Good luck.

Use HTTP POST to send file to IIS 7.5 virtual directory

Is it possible to allow HTTP clients to USE HTTP POST (with Content-Type: multipart/form-data) to upload image files to an IIS 7.5 virtual directory without writing server-side code?
Without server-side code, that is not possible. If HTTP POST is a requirement, you need to write code. Otherwise, configure an FTP site on your IIS installation.
If you really need HTTP, consider WebDav:
http://www.windowsnetworking.com/articles_tutorials/webdav-iis.html
http://learn.iis.net/page.aspx/350/installing-and-configuring-webdav-on-iis/
If you enable public write access in IIS with WebDAV, you can upload files using HTTP PUT requests.
More info.
There are lots of different WAYS you can handle this on the server side ... but all of them involve writing some kind of "code".
SUGGESTION:
Maybe a little asp.net script might be the ticket?
http://msdn.microsoft.com/en-us/library/aa479405.aspx

How do I make my Apache 2 server force a browser to open a file transfer dialogue?

How do I make my Apache 2 server force a browser to open a file transfer dialogue if the URL points to a file with a .pln or .psa extension?
I have a simple LAMP server with CentOS 5, Apache 2, MySQL 5, PHP 5, recently built CentOS 5.2 i386 installation CDs. My web application generates files to be downloaded and imported into a custom application. The file extensions are .psa and .pln. How do I make my server force the browser to open a file transfer dialogue? If I point my browser to a .psa or .pln file on the Apache 2 server, the file's content is displayed in a pop-up window as simple text. I want a file transfer dialogue.
The web-app I am working on is deployed on another web-server and handles the .pln and .psa files as desired. I cannot compare server configuration files because I do not have administrator access to the working server.
How do I change my server's behavior? Does this require code changes to my web-app code (such as sending explicit headers)? If so, why does it work against the other server? Can code changes be avoided by configuring the server's default behavior?
You should be able to use the FilesMatch directive to add the necessary header.
<FilesMatch "\.(?i:pin)$">
Header set Content-Disposition attachment
</FilesMatch>
I tried several configuration changes which had no apparent effect.
I added the following line to my /etc/httpd/conf/httpd.conf file:
AddType application/octet-stream .pln .psa
I restarted the Apache server and it had no effect.
I added the following lines to my /etc/httpd/conf/httpd.conf file:
ForceType application/octet-stream
Header set Content-Disposition attachment
ForceType application/octet-stream
Header set Content-Disposition attachment
I restarted the Apache server and it had no effect.
If you have Firefox (and if not, why not?) install Chris Pedericks Developer Toolbar, and check that the headers are actually being set correctly. If so, it may be the fault of the browser. As I said, you can't be certain that any given browser will "correctly" interpret the response headers. What browser are we talking about here anyway?
If the headers aren't being set correctly, you may need to re-check your httpd.conf file. Possibly the directives you added aren't in the correct section? (e.g. under the wrong <Location > directive)
Forcing a browser to do something is always a tricky proposition, since the browser can ignore you and do what the hell it likes
That said, most browsers will prompt the user with a "save as" dialog box if the "Content-type" header is set to "application/octet-stream". Either write a simple wrapper CGI that serves up the requested file with the correct header, or fiddle with Apache2's mime-types (look in the config directory.)

Resources