Printer Friendly Version
Email this thread to a friend
|
Featured Web Site Template |
|
Reflects user activity within the last 5 minutes
|
|
| Member |
Message |
cybercyst
Joined: May 03, 2005
# Posts: 4
|
Posted: 05/03/2005 11:35 am
hi
does any1 no an upload script for this site >> [url in profile]. in the bands vortex area and the upload files area i need a php script to allow people to upload their stuff.
do i need anything else to allow people to upload their stuff
thanks
[This is a sig-free zone, please keep your url in your profile only and do not place it in your posts.]
[ Message was edited by: JimBot 05/03/2005 04:47 pm ]
|
 |
squirrel
Joined: Eons Ago
# Posts: 120
|
Posted: 06/10/2005 06:34 am
[link] is a good place to start. Everything you will need is there. If you run into any problems post them.
|
 |
omoutop
Joined: Feb 16, 2004
# Posts: 22
|
Posted: 07/08/2005 06:05 am
<html>
<head>
<title>Uploading...</title>
</head>
<body>
<h1>Uploading file...</h1>
<?php
// $userfile is where file went on webserver
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
// $userfile_name is original file name
$userfile_name = $HTTP_POST_FILES['userfile']['name'];
// $userfile_size is size in bytes
$userfile_size = $HTTP_POST_FILES['userfile']['size'];
// $userfile_type is mime type e.g. image/gif
$userfile_type = $HTTP_POST_FILES['userfile']['type'];
// $userfile_error is any error encountered
$userfile_error = $HTTP_POST_FILES['userfile']['error'];
// userfile_error was introduced at PHP 4.2.0
// use this code with newer versions
if ($userfile_error > 0)
{
echo 'Problem: ';
switch ($userfile_error)
{
case 1: echo 'File exceeded upload_max_filesize'; break;
case 2: echo 'File exceeded max_file_size'; break;
case 3: echo 'File only partially uploaded'; break;
case 4: echo 'No file uploaded'; break;
}
exit;
}
// end of code for 4.2.0
// prior to 4.2.0 use manual error checking as below
/*
if ($userfile=='none')
{
echo 'Problem: no file uploaded';
exit;
}
if ($userfile_size==0)
{
echo 'Problem: uploaded file is zero length';
exit;
}
*/
// end older version error checking
// one more check: does the file have the right MIME type?
if ($userfile_type != 'text/plain')
{
echo 'Problem: file is not plain text';
exit;
}
// put the file where we'd like it
$upfile = '/uploads/'.$userfile_name;
// is_uploaded_file and move_uploaded_file added at version 4.0.3
if (is_uploaded_file($userfile))
{
if (!move_uploaded_file($userfile, $upfile))
{
echo 'Problem: Could not move file to destination directory';
exit;
}
}
else
{
echo 'Problem: Possible file upload attack. Filename: '.$userfile_name;
exit;
}
// older versions code as recommended in PHP manual
/*
function is_uploaded_file($filename) {
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
$tmp_file = dirname(tempnam('', ''));
}
$tmp_file .= '/' . basename($filename);
// User might have trailing slash in php.ini...
return (ereg_replace('/+', '/', $tmp_file) == $filename);
}
if (is_uploaded_file($userfile))
{
copy($userfile, $upfile);
} else
{
echo 'Problem: Possible file upload attack. Filename: '.$userfile_name';
}
*/
// end older version
echo 'File uploaded successfully<br /><br />';
// reformat the file contents
$fp = fopen($upfile, 'r');
$contents = fread ($fp, filesize ($upfile));
fclose ($fp);
$contents = strip_tags($contents);
$fp = fopen($upfile, 'w');
fwrite($fp, $contents);
fclose($fp);
// show what was uploaded
echo 'Preview of uploaded file contents:<br /><hr />';
echo $contents;
echo '<br /><hr />';
?>
</body>
</html>
|
 |
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
- You have not yet logged in, or registered properly as a member
- You are a member, but no longer have posting rights.
- This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you cannot find this message, click here to Re-Send it.
|
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.
|
Switch to Advanced Editor and ...
Create a New Topic
or Reply to this Thread
|
|