Home > Archive > PHP Language > March 2006 > Newbie: Automated File Upload ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Newbie: Automated File Upload ?
|
|
| GrImBlY 2006-03-17, 6:56 pm |
| I run a cycling website and my life would be made SOOOO much easier if I
could have a script which would upload all the files in a specific
directory on my hard drive.
I've seen some very elegant solutions which involve the use of a form,
however this is a little over-engineered as the directory will always
stay the same.
Now, I'm sure I've missed something really simple.
I've downloaded a script that appears to do the job, and works fine on
my testing server. However, uploaded it to my website and it gets all
when I set the upload path to "c:\MyPhotos\FilesToUpload"
Any idea how I set the upload path without using a form ?
Thanks in advance....
| |
| Gnutt Halvordsson 2006-03-17, 6:56 pm |
| Is your testing-server on your local computer?
If so, the problem lies in that the "real" is not your computer and the
path "C:\MyPhotos\FilesToUpload" is not aviable on that computer.
You could try the aproach of installing a http, or FTP-server on your
computer, and get it from your computer via the server.
Or if the testing-server is your local machine, use the local webbserver
to post the files.
Don't know if it helped...
//Gnutt
GrImBlY skrev:
> I run a cycling website and my life would be made SOOOO much easier if I
> could have a script which would upload all the files in a specific
> directory on my hard drive.
>
> I've seen some very elegant solutions which involve the use of a form,
> however this is a little over-engineered as the directory will always
> stay the same.
>
> Now, I'm sure I've missed something really simple.
>
> I've downloaded a script that appears to do the job, and works fine on
> my testing server. However, uploaded it to my website and it gets all
> when I set the upload path to "c:\MyPhotos\FilesToUpload"
>
> Any idea how I set the upload path without using a form ?
>
> Thanks in advance....
| |
| GrImBlY 2006-03-17, 6:56 pm |
| Gnutt Halvordsson wrote:
> Is your testing-server on your local computer?
Yes it is!
> If so, the problem lies in that the "real" is not your computer and the
> path "C:\MyPhotos\FilesToUpload" is not aviable on that computer.
>
That's right, how do I get "c:\MyPhotos\FilesToUpload" to point to the
relevant directory on my PC ?
> You could try the aproach of installing a http, or FTP-server on your
> computer, and get it from your computer via the server.
>
> Or if the testing-server is your local machine, use the local webbserver
> to post the files.
I've tried those ideas with no joy..
[color=darkred]
>
> Don't know if it helped...
>
> //Gnutt
>
> GrImBlY skrev:
| |
| Gnutt Halvordsson 2006-03-17, 6:56 pm |
| This is a example on how you could do this (not complete, but should
give you an idea on how to solve it)
Get a FTP-server, such as for example FileZilla Server
start it up, add a user, example "photos" with a pass, and set it's home
directory to "C:\MyPhotos\FilesToUpload\".
If you have a static IP, then use that, otherwise I suggest you use a
DDNS-system (example no-ip.com) so you have a constant connection-info
for your site...
And then with connect to your computer with
$conn_id = ftp_connect("your-home-computer")
ftp_login($conn_id, "photos", "photospass")
Get a list of existing files with
$contents ftp_nlist($conn_id, "");
Check which files are missing on the server and get those with
ftp_get($conn_id, $local_file, $remote_file, FTP_BINARY);
and then close the ftp-session (ftp_close($conn_id));
This is not the whole solution, but part of the fun is to figure the
last bits out yourself...
Hope it helps...
//Gnutt
GrImBlY wrote:[color=darkred]
> Gnutt Halvordsson wrote:
>
> Yes it is!
>
> That's right, how do I get "c:\MyPhotos\FilesToUpload" to point to the
> relevant directory on my PC ?
>
>
> I've tried those ideas with no joy..
>
| |
| Neil H 2006-03-19, 3:55 am |
| Instead of a static IP etc.. couldn't the local IP adress work (i,e,
127.0.0.1)
Regards,
Neil
"Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
news:5KESf.48705$d5.205043@newsb.telia.net...[color=darkred]
> This is a example on how you could do this (not complete, but should
> give you an idea on how to solve it)
>
> Get a FTP-server, such as for example FileZilla Server
> start it up, add a user, example "photos" with a pass, and set it's home
> directory to "C:\MyPhotos\FilesToUpload\".
>
> If you have a static IP, then use that, otherwise I suggest you use a
> DDNS-system (example no-ip.com) so you have a constant connection-info
> for your site...
>
> And then with connect to your computer with
> $conn_id = ftp_connect("your-home-computer")
> ftp_login($conn_id, "photos", "photospass")
>
> Get a list of existing files with
> $contents ftp_nlist($conn_id, "");
>
> Check which files are missing on the server and get those with
> ftp_get($conn_id, $local_file, $remote_file, FTP_BINARY);
>
> and then close the ftp-session (ftp_close($conn_id));
>
> This is not the whole solution, but part of the fun is to figure the
> last bits out yourself...
>
> Hope it helps...
>
> //Gnutt
>
>
>
> GrImBlY wrote:
| |
| Gnutt Halvordsson 2006-03-19, 6:56 pm |
| Sorry... since the local address in not accessible from outside.
IE. 127.0.0.1 is accessible from your local computer only (this is an
internal adress that your computer uses when it needs to talk to itself
via a virtual network connection)
What type of connection do you have? (xDSL, dialup, ISDN or what?)
What type of hardware do you have between your computer and the
internet? (Modem, router)
Therefore a DynDNS-solution might be best for you...
I use the no-ip.com-DynDNS, which gives me a shortname to access my
dialup-router (and that one routes on the requests to the specific
computers)
So if i try to ftp to gnutt.no-ip.org then the no-ip-network checks from
where I last logged in and sends the request to that IP-number.
Neil H skrev:
> Instead of a static IP etc.. couldn't the local IP adress work (i,e,
> 127.0.0.1)
>
> Regards,
> Neil
>
> "Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
> news:5KESf.48705$d5.205043@newsb.telia.net...
>
>
| |
| Ian Hobson 2006-03-19, 6:56 pm |
| In message <tgzSf.37954$ky6.6790@fe12.news.easynews.com>, GrImBlY
<grimbly@NOSPAMbtinternet.com> writes
>I run a cycling website and my life would be made SOOOO much easier
>if I could have a script which would upload all the files in a specific
>directory on my hard drive.
>
I take it they change quite often.
1) Go here to learn about the commands available.
http://www.computerhope.com/software/ftp.htm#02
2) Open a dos box (command prompt) and type ftp
3) Play with the program until you know what to type to put all your
files up.
4) Create a file containing the FTP commands you need. For example.
open ftp.yourdomain.com
username
password
cwd /path/on/server
cd /path/local/machine
hash
prompt off
ascii
mput *.txt
mput *.html
binary
mput *.png
close
bye
Important note 1 - BINARY or ASCII? These switch the way the end of
lines are handled. You MUST set BINARY mode before you transfer image
files and you MUST set ASCII mode before you transfer text files. If you
transfer images in ASCII they will be trashed. If you transfer text in
binary mode may programs will crash when they try to use them.
Important note 2 - chmod executables. Scripts that the server considers
executable (*.pl, *.cgi, etc) must have their execute bits set. If you
need it I think the command is something like "Literal chmod file 755"
5) save the file as myscript.txt
6) Create a shortcut to it, and look at the properties. Edit the command
line from "myscript.txt" to read
ftp -s:myscript.txt
7) Save the short cut.
8) Double click the shortcut!
Hope this helps.
Ian
--
Ian - posting to a Newsgroup. Please remove everything to reply.
|
|
|
|
|