Current location: Hot Scripts Forums » Programming Languages » PHP » PHP upload without using a form


PHP upload without using a form

Reply
  #1 (permalink)  
Old 11-12-07, 06:04 AM
zaher zaher is offline
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-12-07, 06:11 AM
n3wb!e's Avatar
n3wb!e n3wb!e is offline
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-12-07, 06:21 AM
zaher zaher is offline
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

PHP Code:

copy("D:\file.txt",$upload_file_path."/file.txt"); 

Notice the D:\ which is a client side directory.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-12-07, 10:02 AM
mab's Avatar
mab mab is offline
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???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 11-12-07, 11:21 AM
zaher zaher is offline
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 11-12-07, 12:04 PM
mab's Avatar
mab mab is offline
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???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 11-12-07, 12:15 PM
zaher zaher is offline
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 11-12-07, 02:01 PM
Nico's Avatar
Nico Nico is offline
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 11-12-07, 04:46 PM
zaher zaher is offline
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 11-13-07, 12:40 AM
Acecool's Avatar
Acecool Acecool is offline
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...

:-)
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php upload file script xavier039 PHP 5 08-29-06 05:35 PM
submit form in php danlew PHP 11 01-11-06 04:34 AM
Simple order PHP form to Email wearetwo PHP 8 01-06-06 04:33 AM
Web form to upload, and report the file name to database fompsweeva PHP 2 01-04-06 03:18 AM
PHP: Different table entry from same form? Stormrider Script Requests 3 05-07-05 09:19 AM


All times are GMT -5. The time now is 07:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.