473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading a pre-defined filename to a server with PHP


Hi,

I am a complete novice but would liket to have a PHP script which will
upload a file which is pre-defined, without the need for the user to
'Browse' for a file path. For example, the pre-defined file would be
"C:\temp\test.t xt", and the script will already know this value
without the user telling it.

I tried filling the textbox with a file path value, but it doesn't
work with the input type "file", only as a "textbox". So I am now
certain that the PHP code is the only way to maybe solve it, and
hoping someone can help me
Here's the HTML code:

<form enctype="multip art/form-data" action="upload. php" method="POST">

<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_ SIZE" value="30000" />

<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />

<input type="submit" value="Send File" />

</form>

And here's the PHP code:
<?php
$uploaddir = '/home/vhosts/seanlock.275mb. com/uploads/';
$uploadfile = $uploaddir . basename($_FILE S['userfile']['name']);

echo '<pre>';a
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES );

print "</pre>";

?>
If anyone knows of a simple way of achieving what I'm after, I'd be
really grateful for any help.

Regards,
Sean
Sep 6 '06 #1
1 2004
On Wed, 06 Sep 2006 19:59:45 GMT, sean <se*******@nosp mam.blueyonder. co.uk>
wrote:
>I am a complete novice but would liket to have a PHP script which will
upload a file which is pre-defined,
Can't. It's a browser limitation for security reasons.

See also: http://www.w3.org/TR/REC-html40/appe....html#h-B.10.1

Whilst the standard recommends prompting for confirmation, most browsers err
on the side of caution and simply ignore the value attribute.

More: http://www.cs.tut.fi/~jkorpela/forms/file.html

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
17483
by: ok | last post by:
Hello, Q: How do I get image width and height before uploading an image? This because, I want to restrict people uploading huge files. Thanks in advance
0
1323
by: -Jim | last post by:
I've been looking for a solution for this for a bit... I decided to just try and copy and paste the solution from php.net to try and still nothing. //theUpload.php <?php echo"<form enctype=\"multipart/form-data\" action=\"result.php\" method=\"post\">"; echo" <input type=\"hidden\" name=\"MAX_FILE_SIZE\"
5
5479
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
3
2642
by: Jason Chu | last post by:
I've written a file uploading part of my application using the IHttpModule. So now, I don't have the memory problem of uploading something big. Problem: I can't find which function I have to override, so that I can catch the event when while user's uploading a file, then suddenly closes the browser. In that case, couple things happens: 1) ASPNET will start eating up the uploading file on memory instead of on disk (so picture a...
10
1406
by: jodleren | last post by:
Well, I looked at an example from this group, tried it, and tried to use it - but it does not work when I do it like this in PHP4. <table> <tr><td><input type="file" name="newfile" size="25"></td></tr> <tr><td><input type="submit" name="sub_new" value="Upload"></td></ tr> </table></form> and in the same file, but ealier:
0
1504
by: PerumalSamy | last post by:
Hi, I am getting following error while uploading my project in web. Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: File or assembly name CrystalDecisions.CrystalReports.Engine, or one of its dependencies, was not found. Source Error:
1
1121
by: Midgard | last post by:
I have this code: <?php if ($_FILES) { echo '<pre>'; print_r($_FILES); echo '</pre>';
2
2344
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the "Content-Type" HTTP header; even if I don't set an actual HTTP header and I just use a <metatag: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> With a packet sniffer I've determined that it's not the browser who
3
5184
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
11
16173
by: swethak | last post by:
Hi, My Requirement is to upload the images into database through jsp. For that i write a code .And it works fine .But in that File imgfile = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/test/Blue.jpg"); instead of that i used File imgfile = new File("Blue.jpg"); like that it didn't work. When we browse that image from local system it automatically takes like Blue.jpg and didn't take the full path. So i got...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.