I wanted to copy image from any remote server to my local server using javascript / jQuery. Please anyone help me out.
Same like copy() function in php.
Local server? JavaScript/Jquery runs in the client and they cannot access any files directly from a remote server. The client are mostly your browsers.
If you know the file path for your remote server and if your have access to it, you can just open the file using window.open("http://remoteserver/filename.jpg")
This would download the file to the client or your computer.
Related
I have multiple questions
Can we create a directory in client machine ?
Can we check the running browser's default download path?
My requirement is that the user will download a BLOB data from my DB that time I want to create a folder in client machine and use that folder to save the blob data.
Can this be done using javascript,jquery,ajax,php,angularjs ?
You can't create a folder in client PC using JS.(don't even bother looking with HTML and CSS)
The best way you could accomplish something as you describe is to give a .zip to your client, so while extracting it, it creates his own container (the folder). But you must be sure that the people who intend using your web application knows how a .zip works.
Using PHP you can't do anything in the client PC. PHP is a server side programming language. So, it is running only in the server. When you make any request to the server then only PHP performs. In the browser end or client side only HTML, CSS and JS works.
Let's say a pdf document is served at a url, ex - https://www.polyu.edu.hk/iaee/files/pdf-sample.pdf
I need to run a javascript that takes the url and makes a post request to a server with the pdf file data that can be converted back to file. Typical solutions for accessing files on a server location are around downloading on local first and then having the user upload it. How can we bypass the user interference ? Appreciate all inputs and workarounds like using browser cache / local storage etc.
Thanks
This is not possible.
JavaScript executed in a browser runs on the client machine. Thus any modification on a remote resource must be downloaded, modified and uploaded to the server.
As you already stated: using a browser cache or local storage wont help you.
You have to do this modifications on server-side e.g. with a servlet or php. You will need access to the server.
I have a mobile application which needs the user to attach some files from his mobile and upload it on the server.
Is there a way to upload files on the server from mobile using JQUERY/JAVASCRIPT ?
I found many doin it with PHP/ASP.NET-c#...but my need is HTML with JAVASCRIPT/JQUERY...!!
FURTHER INFO ON MY APP (Kindly neglect it if not needed):
I have my front-end in HTML/CSS..I have a WCF service running on my server that does the communication with the database..I use the WCF service by making ajax calls from my client side..
I achieved all the other operations such as insert/delete/update/retrieve data from DB using these services only..
I was wondering if there is any possibility to do the "upload files on the server" task also using these webservices...but didnt get any idea about it !!!
Here is another question exactly precise to my need !! File upload service using WCF along with jquery(AJAX) and html client
Sorry if i m wrong anywhere..This stuff is totally new to me and so i need all your guidance..
To save an uploaded file, you need an server side script (PHP, ASP e.g.) to move the uploaded file from the servers tmp directory, to your desired location.
Maybe can you edit your serves configuration so it writes the uploaded files automatic to your desired location, but I wouldn't suggest that due to security reasons.
Is this a native application? If it's just a website then you'll struggle as safari on iPhone doesn't support file uploads. If it's a phonegap application you could maybe hook into the file API...
Ok some of the points worth mentioning.
When you wanted to upload file to server you have to POST file with multipart content type of the form. For this you might need to write WCF service on server end accordingly. I am not having good experience of WCF but this post should help may be
<form method="POST" enctype="multipart/form-data" >
HTML5 file API and XHR Level 2 specification you can upload files to server. As they are new features and JS and DOM involved yes you can consum and do it in JQuery as well as long as your browser is supporting them.
With these things i am not sure if there should be any issue while uploading files to the server.
anyone knows a way how i can copy a image from a remote server in a local directory via jQuery or JavaScript?
via php copy or cURL its not allowed on my webspace.
best regards
Is it possible to connect to a server and FTP a file from within PhoneGap application? Basically I suppose - is there a way to open an FTP connection with Ajax/JQuery somehow?
I don't think you will be able to FTP a file from PhoneGap however they do provide an API for transferring a file to a server using HTTP multipart encoding:
http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer
You would need a script on the server in your chosen technology to receive the file however you should then be able to do whatever you like with it, including move it to the directory you are trying to FTP to
Ftp program for phone gap is here please see this bellow link.
https://github.com/macdonst/FtpClient