Upload file without User Interaction

Reply

Join Date: Jan 2007
Posts: 47
Reputation: kapil.goyal is an unknown quantity at this point 
Solved Threads: 0
kapil.goyal kapil.goyal is offline Offline
Light Poster

Upload file without User Interaction

 
0
  #1
May 3rd, 2007
can anybody tell me how i can upload a file without user interaction.the file full path is known and can be hardcoded.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,073
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Upload file without User Interaction

 
0
  #2
May 3rd, 2007
Originally Posted by kapil.goyal View Post
can anybody tell me how i can upload a file without user interaction.the file full path is known and can be hardcoded.
Uploading from Client to Server

I'm assuming that you want to upload a file from a client to your server. The client being the web browser.

This is not possible under normal security conditions on the major browsers.

It can only be achieved if the browser settings have been changed to allow a certain website to upload automatically. Such as in an intranet.

On a normal browser, the DOM node representing the upload field has a value that is read only. So you cannot write a file path to it.

Even if you have the following:

[HTML]<form method="post" enctype="multipart/form-data">

<input type="file" name="autofile" value="C:\Documents and Settings\Owner\My Documents\file.zip" />

</form>[/HTML]

The value will not be set to the file input.

This really is a browser issue, not a PHP one. It restricts any client side script language that accesses the DOM, such as JavaScript, Actionscript, VBScript etc.
I haven't tested on ActionScript or VBScript though.

Uploading from Server to Server

If you instead wanted to upload a file from a remote server to your server using PHP, then it is very simple.
[PHP]
<?php

$contents = file_get_contents('http://example.com/file.zip');

?>[/PHP]

That would download the imaginary file 'http://example.com/file.zip' to your php application via a TCP socket.
Then you can write the file to your filesystem:

<?php

$contents = file_get_contents('http://example.com/file.zip');
$fp = fopen('/path/to/file.zip', 'wb');
fwrite($fp, $contents, strlen($contents));
fclose($fp);

?>

That will write the file to '/path/to/file.zip'.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 47
Reputation: kapil.goyal is an unknown quantity at this point 
Solved Threads: 0
kapil.goyal kapil.goyal is offline Offline
Light Poster

Re: Upload file without User Interaction

 
0
  #3
May 3rd, 2007
any body else can help me.i have made an active-x control for tat but to install the active-x control user have to low down his security level.
any solution?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,073
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Upload file without User Interaction

 
0
  #4
May 3rd, 2007
Originally Posted by kapil.goyal View Post
any body else can help me.i have made an active-x control for tat but to install the active-x control user have to low down his security level.
any solution?
It anything, I'd suggest using flash/actionscript rather than using an active-x.
Active-x is a proprietary implementation by micro$oft on windows and and thus IE.

Active-x does not exist on mozilla/Firefox, Safari, Netscape, Opera etc. which is a lot of the browser market.

If you use active-x then you'll have to also use XUL also, which is mozilla's User Interface, and other stuff specific to each other browser. Then you can achieve what you want on the majority of browsers.

Flash, is installed on 90% of browsers (they claim). So it would be the widest implementation of what you want to achieve.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC