Uploading files to website

liunx

Guest
Hi everyone,<br />
<br />
I want a user to to log onto our intranet site; and on a specefic webpage they go to they will have the facility to upload to my specified directory which i have put in the code.<br />
<br />
All there needs to be is a form that has a browse function and an upload button. its just the code to that I'd like if someone can help..<br />
<br />
thx<!--content-->If your server supports PHP, search that section, as I know I've posted a script to do this, before.<!--content-->Hi Pyro, I found your post:<br />
<br />
<html> <br />
<head> <br />
<title>Upload a File</title> <br />
</head> <br />
<body> <br />
<br />
<br />
<br />
<?PHP <br />
<br />
$uploaddir = "uploads"; # must be chmoded to 777 <br />
<br />
if ($_POST['submit']) <br />
{ <br />
$name = $_FILES['File']['name']; <br />
$tmpname = $_FILES['File']['tmp_name']; <br />
$size = $_FILES['File']['size']; <br />
<br />
if (copy ($tmpname, "$uploaddir/$name")) <br />
{ <br />
print ("File Name: $name<br/><br/>\n"); <br />
print ("File Size: $size<br/><br/>\n"); <br />
print ("Your file was successfully uploaded!<br/><br/>\n"); <br />
} <br />
else <br />
{ <br />
print ("Your file could not be uploaded."); <br />
} <br />
unlink ($tmpname); <br />
} <br />
<br />
?> <br />
<br />
Upload a file to the server <br />
<br />
<form action="upload.php" method="post" enctype="multipart/form-data"> <br />
File: <input type="file" name="File" size="20"><br/> <br />
<input type="submit" name="submit" value="Upload File"></form> <br />
<br />
</body> <br />
</html> <br />
<br />
I just can't see where the file will eventually be uploaded to on the server, do I have to change something?<br />
<br />
Thanks<!--content-->This line:<br />
<br />
$uploaddir = "uploads"; # must be chmoded to 777 <br />
<br />
specifies which directory the files will be uploaded to. In this case, it will be uploaded to uploads, which must be a subdirectory of the directory that the upload script (upload.php) is in.<!--content-->thx 4 your help, really appreciated. <br />
I have one more question to ask,<br />
I would like my users to Download <!--more--> the files from the upload folder, is these a way of doing this?<br />
i.e. Browse for the file and then push Download <!--more-->?<br />
Im quite inexperienced with forms<br />
thanks<!--content-->You'll probably have to make a listing of all the files in the directory, and then use something like this (<!-- m --><a class="postlink" href="http://www.infinitypages.com/research/Download">http://www.infinitypages.com/research/Download</a><!-- m --> <!--more-->.htm) to force the Download <!--more-->.<!--content-->Sorry for bumping a really old thread, but this script is great! Just what I've been looking for...although I do have one question. I know very little of PHP and was wondering whether the code can be changed to allow the user to name and/ or create (and chmod, I suppose) the directory in which they want to upload to? I know there are risks associated with this, but this is going to be for a couple of friends of mine to use for uploading images to host on my site.<br />
<br />
*Edit: I just realized this is in the HTML forum. Sorry. :(<!--content-->Yes, it's possible.<br />
<br />
I suggest that you require a username and password to use a script like that though.<!--content-->Yes, it's possible.<br />
<br />
I suggest that you require a username and password to use a script like that though.<br />
<br />
That's absolutely my intention. Okay, I'll go dig around in the PHP forum. thanks!<br />
<br />
Tom<!--content-->
 
Back
Top