I know it has nothing to do with filesize because I am the server and I set the 
configuration.  But lemme show you some code, maybe that'll help.  Here we go:  

(please no ripping)
function MyFiles() {
global $username, $Upload, $Rename, $Delete, $PHP_SELF, $File, $File_size, $File_name, 
$File_type, $page, $src;
echo "<table bgcolor=#CCCCCC width=60% cellspacing=0 cellpadding=2 align=center>
<tr><th bgcolor=#888888 colspan=6>My Files</th></tr>";
$Folder = "article_files";
if(isset($src)) {
FileDetails($src);
Close();
}
if ($Upload) {
$File_name = strtolower($File_name);
$File_name = ereg_replace(" ","_","$File_name");
$File_name = ereg_replace("#","hash","$File_name");
$upfile = "../$Folder/$File_name";  
if($File_name == "$PHP_SELF" or $File_name == "resize_image.php" or $File_name == 
"login.php" or $File_name == "logout.php" or $File_name == "latest.txt" or 
eregi("index",$File_name)) {  
echo "<tr><td colspan=6 align=center>For security reasons, your file could not be 
uploaded.<p></td></td>\n";
}
elseif(copy($File,$upfile)) {
if(is_uploaded_file($File_name)) {
echo "<tr><td colspan=6 align=center><hr>Your file, <a href=$File_name>$File_name</a>, 
was successfully uploaded.</td></tr>\n";
FileDetails($File_name);
$time = time();
$query = "insert into article_files 
values(null,'$username','$File_name','$File_size','$File_type','$time')";
mysql_query($query);
} else {
echo "<tr><td colspan=6 align=center>Your file was not copied.</td></td>\n";
}
}
//unlink ($File);
Close();
}
if($Delete) {  
for($i=0; $i<count($Delete); $i++) {
echo "<tr><td colspan=6 align=center><hr></td></tr>";
if(unlink("$Delete[$i]")) {
echo "<tr><td colspan=6 align=center>Your file, $Delete[$i], was successfully 
deleted.</td></tr>\n";
} else {
echo "<tr><td colspan=6 align=center>Your file, $Delete[$i], could not be 
deleted.</td></tr>\n";
}
}
Close();
}
if($Rename) { // Handle file renaming
for($n = 0; $n < count($Rename); $n++) {
$OldFilename = $Rename[$n];
$NewName[$OldFilename] = strtolower($NewName[$OldFilename]);
$NewName[$OldFilename] = ereg_replace(" ","_","$NewName[$OldFilename]");
$NewName[$OldFilename] = ereg_replace("#","number","$NewName[$OldFilename]");
$Old = "$OldFilename";
$New = "$NewName[$OldFilename]";
echo "<tr><td colspan=6 align=center><hr></td></tr>";
if(rename($Old, $New)) {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], was successfully renamed 
to <a href=$NewName[$OldFilename]>$NewName[$OldFilename]</a>.</td></tr>\n";
} elseif($New=="manage.php" or $New=="index.php" or $New=="index.html" or 
$New=="index.htm" or $New=="index.shtml" or $New=="index.shtm" or $New=="index.asp" or 
$New=="login.php" or $New=="logout.php" or $New=="files.php" or 
$New=="resize_image.php" or $New=="latest.txt") {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], could not be 
renamed.</td></tr>\n";
} else {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], could not be 
renamed.</td></tr>\n";
}
}
Close();
}
echo "<form action=$PHP_SELF method=post enctype=multipart/form-data>\n
<tr><td><b>File Name</b></td><td><b>File 
Size</b></td><td><b>Added</b></td><td><b>Delete</b></td><td><b>Rename</b> (Enter new 
name in the box)</td><td><b>Details</b></td></tr>\n";
$query = "select * from article_files where owner='$username' order by filename asc";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$Size = $row[filesize];
$Size = $Size/1023;
if($Size < 1023){
$Size = number_format($Size, 2);
$Size = $Size." kb";
} else {
$Size = $Size/1023;
$Size = number_format($Size, 2);
$Size = $Size." mb";
}
$type = GetExtension($row[filename]);
if($type == "jpg" or $type == "gif" or $type == "png" or $type == "txt" or $type == 
"sql")
$details = "<a href=$PHP_SELF?page=$page&src=$row[filename]>Details</a>";
else
$details = "N/A";
$Date = date("m/d/y", $row[filedate]);
echo "<tr>
<td><a href=../$Folder/$row[filename]>$row[filename]</td>
<td>$Size</td>
<td>$Date</td>
<td>  
<input type=checkbox name=Delete[] value=\"$row[filename]\">
</td>
<td>  
<input type=checkbox name=Rename[] value=\"$row[filename]\">
<input type=text name=NewName[$row[filename]]>
</td>
<td>
$details
</td>
</tr>";
}
echo "<tr><td colspan=6 align=center>&nbsp;</td></tr>";
echo "<tr><td colspan=6 align=center><hr></td></tr>";
echo "<tr>
<td colspan=6 align=center>  
<input type=checkbox name=Upload value=Yes>
Upload a file:  
<input type=file name=File size=20>
</td>
</tr>
<tr>  
<td colspan=6 align=center>  
<input type=hidden name=page value=$page>
<input type=submit name=myfiles_submit value=Submit>
</form>
</tr>
</form>
</table>\n
}

All that is included within a main program and when you send data out from this it 
gets looped back into itself with the global statements, that's the idea anyway.  
However, $File_name always turns up null, (as well as the other operators) which makes 
uploading not possible.
----- Original Message -----
From: SenthilVelavan
Sent: Friday, June 14, 2002 10:49 PM
To: Nathan Taylor; php-general
Subject: Re: [PHP] Confusion with the $_name $_type $_size Variable Extensions

-Lakario,
                Please have a look on
http://www.php.net/manual/en/features.file-upload.php  for more information
on fileuploads in php.Also check with the size of the files you have
transferred.When file size is large, then your files won't get uploaded.This
is due to the low execution time,If you don't mind please send your programs
to dig more.
regards,
SenthilVelavan.P

----- Original Message -----
From: "Nathan Taylor" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Saturday, June 15, 2002 6:46 AM
Subject: [PHP] Confusion with the $_name $_type $_size Variable Extensions


I am having a lot of trouble with the $_name, $_size, and $_type
variable extensions.  I have a basic file upload system however it is
within a function.  Sometimes when I declare the aforementioned
variables in a global statement such as global $file_name I can get a
value for _name, other times, I get nothing.  Can someone clarify
this because I was unable to find anything in the manual?

Cheers,
------------
Lakario
ModDev.netGet more from the Web.  FREE MSN Explorer download :
http://explorer.msn.com



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpGet more from the Web.  FREE MSN 
Explorer download : http://explorer.msn.com

Reply via email to