can anybody tell me how i can upload a file without user interaction.the file full path is known and can be hardcoded.

Dani AI

Generated

Short answer: a normal web page running in a browser cannot silently upload a local file for the same reason explained — browsers block programmatic access to arbitrary local files. If the file truly lives on a server or a network share that your server can reach, have the server fetch it. If the file is only on the user’s PC, you must run code on that PC (an installed agent, service, or an approved extension) — there is no secure way to do it from a vanilla web page.

Practical options (pick the one that fits your environment):

  • Server‑pull: if the file is accessible by URL or a network path (SMB, NFS), let your server retrieve it over HTTPS/SFTP/WebDAV. This requires no browser changes and is simplest when the file isn’t strictly “local” to the end user.

  • Client push via an installed agent: ship a small signed program, Windows service, scheduled task, or script that runs under the user/machine account and pushes the file to your server (HTTPS or SFTP). This allows fully automatic uploads, retry logic, and controlled permissions. Example uploader invocations are as simple as a curl POST from the agent:

    curl -F "file=@C:\path\to\file.zip" https://yourserver/upload
  • Managed deployment / intranet-only: if you control the client machines, deploy the agent with group policy or an installer. This avoids asking users to lower browser security (which is what ran into with ActiveX).

What to avoid and troubleshooting tips:

  • Avoid relying on ActiveX or unsigned browser plugins: they’re platform/IE‑specific and require reduced security settings. Flash/Applets suffer similar install/compatibility issues and are no longer reliable choices.
  • If you use an agent and uploads fail, check service account permissions to the file path, firewall rules, and whether the process runs with sufficient privileges (UAC on Windows).
  • Always use encrypted channels (HTTPS/SFTP), strong authentication (API tokens or key pairs), and avoid storing plaintext credentials on client machines. Sign installers and document rollback/recovery for failed uploads.

Recommendation: if the file can be reached from the server, use server‑pull. If it must come from a user machine and automation is required, build and deploy a small, signed uploader/agent rather than trying to bypass browser security.

Recommended Answers

All 3 Replies

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:

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

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

</form>

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

$contents = file_get_contents('');

?>

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

<?php

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

?>

That will write the file to '/path/to/file.zip'.

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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.