I have a file that changes every day for my website and I want to make a program that takes it from the FTP server and either downloads it to my phone or my laptop.
How would I go about making this and what code do I use?
A few options not already mentioned:
If you have access to the ftp server, a cron job could email the file to you each day.
You could create a web page populated with the data, using jsp, php, or servlet etc. to read the file from disk.
If you're familiar with rsync, you could simply rsync the file to your laptop
Sync the file using Dropbox
Related
I know it sounds strange. I've a php file on my server which is responsible for handling uploads. And a java program on my desktop sends files to this php file. I want to cancel the file upload process to the server whenever I want. So I want to create a kind of stream or something like that to stop ongoing upload process.
I tried to use PIDs to stop a php file's running. But a php file doesn't start running before the client finished uploading.
I want to run the "savePid()" function before the upload started. So I can get the PID and stop running of the file whenever I want.
<?php
include('func.php');
savePid(); //run this before upload started
$in = stream_get_contents(fopen("php://input", "rb"));
$out = fopen('pipeupload.txt', 'w');
while ( ! feof($in) ) {
fwrite($out, fread($in, 8192));
}
?>
I know this won't work. I'm just looking for a solution to stop an ongoing upload process.
It might be possible on server side.
Example :
You have 20 images, every image is more than 2 mb in size. Your java
file from desktop send array of url's of images which is ready to
upload by php file as you told. In the php file you have to do some
change, before every image upload you have to check in database
(create table and add new field image_cancel or add this field in your
prev table, set default value is false) column name image_cancel is
true/false. if it true then stop execution and exit. Now create a new
script cancel_image.php ---> Write code inside and set image_cancel
field true.
This is not an easy thing to do.
There are couple of options I can think of, but both are not easy. Easier first
First Method:
You should have 2 PHP scripts one for handling the upload (which you have now) and another to notify the client to abort. The client should upload to the upload script as you are doing now, and also regularly check if an abort is posted at the notify script. Once the client finds abort it aborts the rest of the upload. Thus your file never reaches the PHP file handling the upload. This method requires the client to handle the abort. A client not respecting the abort still can upload the full file.
Second Method:
You should write your own file handling module or application instead of the normal web server. You can also write apache module which hooks into file upload (if your web server is apache). But this method is more complex and will not run on web servers if you are not hosting it. This method requires patching the webserver or installing application working at system level, and I don't think any administrator will allow this on their server.
The web application is developed with Java/Jsp. One thing I want to do is download a directory from FTP to one user client pc. Since there are at least 700MB of files to be transferd in the directory, and the FTP download speed is sometimes very slow. When I was using an ativex to do the downloading, the web page just got stuck for a very long time. And when the downloading is done, the session times out. So how can I solve the downloading and the timeout things?
you can take reference from here
http://www.codejava.net/java-se/networking/ftp/how-to-download-a-complete-folder-from-a-ftp-serverIt worked for me
I need to save some image files from user directory to the project folder on server, but I cant find working solution. What is the simplest way to select file in users pc and copy it to the server? And what url may I use to acces this file?
Run an FTP(S) server, and use a Java FTP client to connect and upload the files.
You can make the FTP home directory a subfolder of wwwroot on your server, so you can access the uploaded files as "example.com/diagrams/mydiagram".
Beware though, the client must have the FTP password to connect, therefore your users can upload anything they want (including malicious scripts). If you don't trust your users, you'll need per user auth and verification of the uploaded files, which will require server side code.
I have created an applet which creates a file on running it. But when I run my applet via server, it fails.
Is there any possible way to create a file on server with applet?
EDIT:I am creating a sound record applet which works fine when I run the applet in browser locally.It actually creates a file of recorded sound,but when I run the same applet on server,it does not create file.Is it because the server does not allow you to do so?
Is there any possible solution so that the file can be created?
File objects always point to a location (that may not exist) on the client machine.
To store something on a server, it would require some server side functionality to accept the bytes and create a (server-side) File. That might be done with PHP, servlets/JSP, ASP etc. Once the server-side is organized to accept the bytes, the applet can connect to it and push the sound recording through.
Java Applets are run on the client machine. Once you invoke the page containing an applet, the applet gets downloaded to the client's machine and runs. Hence it will not get access to the server.
I have added functionality which will enable the user to attach a file from web page.
and this file will be sent as an attachment to another user.
When I try this on my local machine it works fine.
I deployed the application on the server.
And when I am trying to attach a file its throwing FileNotFoundException.
Kindly help.
You seems to be reading file system assuming that client is always on server.
Server and Client are different things. Client may be / May not be [all most all the time] on server. You need to upload file then read..
If you can read client's flle system this easily, then we might not have coined the word security