PHP upload without using a form

11-12-07, 06:04 AM
|
|
Newbie Coder
|
|
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
PHP upload without using a form
Hello,
I'm familiar with the way PHP handles file uploads when it comes to using a form that calls a php file to perform the uploading.
However, i'm seeking a way to upload files without having to select them using a form. Simply, it is a tool which already knows what files and folders' content must be uploaded/updated on the server, so you just have to run it and it will read the specified set of files or one file and upload it automatically.
The problem I faced while trying to figure out a way around this is that PHP uses $_FILE to handle file uploads, and you can have this ($_FILE) only when you are using an upload form, and i never got around some other way to read files.
Anyone got some idea ?
Many thanks
|

11-12-07, 06:11 AM
|
 |
Wannabe Coder
|
|
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
You can use copy to do the same if you know which file/files has to be 'uploaded'.
http://in2.php.net/copy
__________________
i am still a learner and i like $this->  smilie!
|

11-12-07, 06:21 AM
|
|
Newbie Coder
|
|
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I used copy before, but the problem i faced was accessing the client's local dirs.
Is it possible to pass a source paramter for copy(); which is a local address?
something like
Notice the D:\ which is a client side directory.
|

11-12-07, 10:02 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Copy() cannot access a visitor's computer. The remote URL that copy() is able to access requires a remote server listening to the http/https protocol, ie. a web server.
The http/https protocol that browsers and web pages use to exchange information is only able to upload a file using the browser's form input type="file".
A web page that could grab specific files without the visitor selecting them is called a virus and cannot be done using php. If you have a legitimate need to automatically upload specific files, then you would need to write an application program that is downloaded and installed on a client's computer/browser. PHP cannot do this.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|

11-12-07, 11:21 AM
|
|
Newbie Coder
|
|
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Copy() cannot access a visitor's computer. The remote URL that copy() is able to access requires a remote server listening to the http/https protocol, ie. a web server.
The http/https protocol that browsers and web pages use to exchange information is only able to upload a file using the browser's form input type="file".
A web page that could grab specific files without the visitor selecting them is called a virus and cannot be done using php. If you have a legitimate need to automatically upload specific files, then you would need to write an application program that is downloaded and installed on a client's computer/browser. PHP cannot do this.
|
Thank you for your reply. Okay now you made it totaly sure for me that there is no way using PHP.
Can a combination of JavaScript-php handle such a situation?
|

11-12-07, 12:04 PM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A form's file input field cannot be written to by javascript, nor can you set it using a value="..." parameter. This has been tried before, which is why you cannot find a working script that does this. This cannot be done using just a browser's built in file upload function.
It would take a java applet or a compiled application running on a visitor's computer.
You could FTP files, but probably not automatically.
If you describe what it is you are actually trying to achieve, someone could provide direction on if or how it can be done.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|

11-12-07, 12:15 PM
|
|
Newbie Coder
|
|
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for your reply mab.
Alright so regarding JAVA applets, well i know that some restrictions are put on applets, does locating a folder and upload its content automaticaly or lets say by just one (next or upload) button work with applets without any security constraints??
Well simply what i am try to do is something like a synchronize tool for a specific folder that we know about which contains files and subfolders that must be uploaded to server as new or to update exsiting data there.
The tool will locate the folder in a preset path on the client machine, and read its content into an array or something and start uploading them either once you turn on the application or after you click some button.
Thank you
Last edited by zaher; 11-12-07 at 12:22 PM.
|

11-12-07, 02:01 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
Flash does also have access to the file system, and it allows uploading.
I'm not sure if it's possible to do what you're trying to achieve though.
|

11-12-07, 04:46 PM
|
|
Newbie Coder
|
|
Join Date: Nov 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It must be without the user manually selecting each file, or the whole concept would be different.
|

11-13-07, 12:40 AM
|
 |
Aspiring Coder
|
|
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Make a file, body onload make it post a form with javascript containing the locations of the files, done...
:-)
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|