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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script: How Uploading Files

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi there,

I need a script that enable me to upload files to the webserver without using an FTP cause I have employees that need to upload some files on the web, but I don't want to give them full access to my files on the net by giving them the password.

So, any script (easy and not complicated, so I can modify it) that let me to have a php page with a password enabled my staff to upload files to the webserevr.

Or even if there is an easy tutorial for creating the upload script.

HaVe a GooD DaY ;)

Ali
 
Heres some code to do basic image upload and validation, lplus displaying size and name etc etc, modify it to fit your needs :)

----------image uploader.php-------------------
<?php

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

echo &quot;Temp name: $userfile <br>Name: $userfile_name <br>Size: $userfile_size<br> type: $userfile_type <br>&quot;;

if ($userfile_name != &quot;.&quot; && $userfile_name != &quot;..&quot; && (ereg(&quot;\\.gif\$&quot;,$userfile_name) || ereg(&quot;\\.jpg\$&quot;,$userfile_name))) {

echo &quot;File: [$userfile_name] is an image&quot;;
echo &quot;<hr>&quot;;
copy($userfile, &quot;../uploaded/$userfile_name&quot;);
Echo &quot;<img src=../uploaded/$userfile_name>&quot;;
unlink($userfile);
}else{

echo &quot;$userfile is not an image<br>&quot;;
if (file_exists($userfile)) {
unlink(&quot;$userfile&quot;);
echo &quot;File: $userfile DELETED!&quot;;
}
}

}else {

echo &quot; <form enctype=\&quot;multipart/form-data\&quot; action=\&quot;$PHP_SELF\&quot; method=\&quot;post\&quot;>
<table width=\&quot;100%\&quot; border=\&quot;0\&quot; cellspacing=\&quot;0\&quot; cellpadding=\&quot;0\&quot; align=\&quot;center\&quot;>
<tr>
<td>
<div align=\&quot;center\&quot;>
<input type=\&quot;hidden\&quot; name=\&quot;MAX_FILE_SIZE\&quot; value=\&quot;100000\&quot;>
<input name=\&quot;userfile\&quot; type=\&quot;file\&quot;>
<input type=\&quot;submit\&quot; value=\&quot;Send File\&quot; name=\&quot;submit\&quot;>
</div>
</td>
</tr>
</table>
</form>&quot;;
}

?> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Hi KarveR,

Thnx 4 ur help, the script works fine with text files, but with iamges, all the images get correpted when they reached the server!

Any idea?

HaVe a GooD DaY ;)

@li @l$@ff@R
 
Odd, works fine for me on 3 different systems.
Anyone else clues? ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top