Page 2 of 2
Posted: Thu Jun 26, 2003 11:02 pm
by DuFF
Good news, I got it to work. Just a tip: when you're having trouble sometimes its just that the variable isn't what it's supposed to be. In order to debug I like to echo() all the variables right before the function just to make sure that they are all what I want them to be. In this case I just called the following line before the first if statement.
Code: Select all
<?php
echo "Filename=$filename<br>Extension=$extension";
?>
I noticed that the $extension displayed was "zip" and not ".zip". I forgot that explode() takes out the period. I then changed the upload extension variables to
Code: Select all
<?php
$uploadext1="zip";
$uploadext2="ZIP";
?>
The script then worked perfectly. Let this be a lesson to all of us

.
Posted: Fri Jun 27, 2003 12:56 pm
by stonerifik

thank you so much! it is working perfectly now... ill take ur advice on the tip thank you!
Posted: Sun Jun 29, 2003 9:40 pm
by stonerifik
sorry for this... but yeah the code i did still works.. but instead of saying successful, it says error...
Code: Select all
<?
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/downloads/".$_POST['directory']."/";
$uploadext1="zip";
$uploadext2="ZIP";
list($filename,$extension) = explode(".",$_FILES[file1][name]);
if($extension==$uploadext1 || $extension==$uploadext2)
{
if ($_FILES[file1] != "") {
copy($_FILES[file1][tmp_name], $uploaddir .$_FILES[file1][name]) or die("Couldnt Upload File");
}
else {
die("No file selected for upload");
}
}
else {
die( "File is not the correct format, only .zip is allowed.");
}
?>
<HTML>
Upload Successful
</HTML>
i dont know what is wrong.. plz help... sorry again
Posted: Sun Jun 29, 2003 10:11 pm
by stonerifik
well after messing with it a couple hours.. i learned that, that file uploaded needs to have mass, or rather size to it... like if i created an empty zip file and tried to upload it, it would give the error, but if i added any size into the file it would be successful, so yeah that was my problem, sorry for wasting ur time if u read this