Jump to content

Archived

This topic is now archived and is closed to further replies.

iambaz

Copying Files from Local Machine

Recommended Posts

Hi,

I am trying to create a script that will upload a file from my local machine onto my web server. I do not want to use a form, I want it to be automated within the script. I have looked for tutorials, but all seem to deal with copying files around the server but not from the local machine.

Is this possible? If so, could somebody point me in the right direction? Any help would be apreciated.

Cheers

Share this post


Link to post
Share on other sites
it might be possilbe if your server IS your local machine - but otherwise you HAVE to use a form that has the client side user select a file to upload.

it would be a pretty big security problem if you could just start uploading files to your website from any user's computer.

Share this post


Link to post
Share on other sites
If your local machine is running php take a look at the [url=http://php.net/ftp]ftp[/url] functions.

Share this post


Link to post
Share on other sites
This implies the server has absolute control over your machine.
As micah said, you have SOME options if you're on localhost, because you may be able to execute commands to move files around but that would be moving files on the server which you mentioned it was not. So there isn't an answer from me. :)

Share this post


Link to post
Share on other sites
Ok, well slightly off topic but a continuation of the original problem, does anybody know if it is possible to upload a file through a form but without the file upload dialogue box, ie php could get a local file path from database, and then through a form, this file is uploaded and then I could get it with $_FILES var using PHP? Basically I would be eliminating the users choice of what file to upload and replacing it with a pre set filepath.

I know this is probably going to be a javascript so apologies, but if anybody knows if it is possible or not, that would be great.

Thanks in advance

Share this post


Link to post
Share on other sites
I'm not aware of a way to change the value of a file input but I have seen implementations of multiple uploads through Javascript, but it still seems a bit intrusive which may mean that it is not supported.

Share this post


Link to post
Share on other sites
Hmmm, yes I never really tought the implications of it through properly. Back to the drawing board!

Thanks for your help!

Share this post


Link to post
Share on other sites
What exactly is it that you want?  A way to add new files to a server automatically?  Because I know there are many ways to do this with a FTP program (at least on a mac, though I imagine there are even more ways to do it with Windows).  This would allow you to say, put a file in a "dropbox" folder that is checked nightly for updates and sync'd with the server.  If you wanted to add some extra bells and whistles - say update a DB with a new table entry representing the new file - you could create a cron script that runs nightly (but after the FTP one) and executes some PHP.  For example it might check the uploads folder on your server and if it finds a new file it adds it to the DB.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.