Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow visitors to upload files

Status
Not open for further replies.

NigeB

Technical User
Nov 29, 2000
53
GB
I currently have a website in which I wish to create a form to allow users to upload files, mainly PDF. Unfortunatly the server is does not allow annoymous posts, the page will ulitmatly be protected by a passowrd entry (already done), but I need to know how to have the user name and password to access the server incorporated, it would also be advantagous not to have these fields visable or at least encrypted.


Any ideas?

Many thanks

Nigel
 
Hi Nigel,
need more info, like where is the PDF going to be stored?
i'm not sure what you mean by "access the server incorporated". What is the password for?- is it to access the page or just to upload and store something on the server.

cheers Ken
 
Basically the file is to be stored in a directory on the web server. What I would like to do is cut out the middle man - ME!

Normally a person emails me the pdf file, I then upload it to the webserver using either dreamweaver or an ftp program.

My server does not allow annonymous access, so I would like to build in a script to a web page to allow the person(s) to upload directly.

Any ideas?

Regards

Nigel.
 
the upload part is easy , the trick is to move the uploaded file to the directory. you'll need to give the webserver access to write to the directory.

- create a form to upload file
- the file will be stored in a temp directory(most of the time)
- within your script, copy the upload file to your directory.

Ken

--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Try this and see if it will work:

<html>
<head>
<title>Upload</title>
</head>
<body>



<?php
if($submit) {

echo &quot;<h1>Uploading file...</h1>&quot;;

if($userfile == &quot;none&quot;) {
echo &quot;no file uploaded<br>\n&quot;;
exit;
}
if($userfile_size == 0) {
echo &quot;no size to your file!<br>\n&quot;;
exit;
}
if(!is_uploaded_file($userfile)) {
echo &quot;possible file upload attach<br>\n&quot;;
exit;
}

$upfile = &quot;/home/ipacdev/inlandpac-
if(!copy($userfile,$upfile)) {
echo &quot;copy failed!<br>\n&quot;;
exit;
}

echo &quot;File uploaded successfully<br><br>&quot;;
}
?>

<form enctype=&quot;multipart/form-data&quot; action=&quot;<?php echo $PHP_SELF; ?>&quot; method=&quot;post&quot;>
<input name=&quot;userfile&quot; type=&quot;file&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Upload&quot;>
</form>

</body>
</html>

If it will not, you won't have much luck getting anything to work unless the PHP on your server has ftp enabled (use PHP's ftp functions).

If this does not work, and you do have PHP's ftp API enabled, then I have a script you can use that works like a charm.

chad. ICQ: 54380631
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top