heracleitus_16
09-10-2005, 04:49 AM
This coding wil aloow you to make file uploads fron your site :)
Create a file called upload.php and enter the following
<html>
<head>
<title>Sample Upload Script</title>
</head>
<?php
// Below must be the absolute path to the directory
$file_dir = "/location/to/the/directory/to/load/files";
// Below is the URL fo the directory
$file_url = "http://www.domain.com/upload/directory";
foreach( $HTTP_POST_FILES as $file_name => $file_array )
{
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if ( is_uploaded_file( $file_array['tmp_name'] ) && $file_array['type'] == "image/gif" )
{
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name") or die ("File cannot be copied");
print "<img src=\"$file_url/$file_name\"><p>\n\n";
}
}
?>
<body>
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="25600">
<input type="file" name="fupload"><br>
<input type="submit" value="Upload File">
</form>
</body>
</html>
The script will upload as your httpd user.
Create a file called upload.php and enter the following
<html>
<head>
<title>Sample Upload Script</title>
</head>
<?php
// Below must be the absolute path to the directory
$file_dir = "/location/to/the/directory/to/load/files";
// Below is the URL fo the directory
$file_url = "http://www.domain.com/upload/directory";
foreach( $HTTP_POST_FILES as $file_name => $file_array )
{
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if ( is_uploaded_file( $file_array['tmp_name'] ) && $file_array['type'] == "image/gif" )
{
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name") or die ("File cannot be copied");
print "<img src=\"$file_url/$file_name\"><p>\n\n";
}
}
?>
<body>
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="25600">
<input type="file" name="fupload"><br>
<input type="submit" value="Upload File">
</form>
</body>
</html>
The script will upload as your httpd user.