Marian -
I think possibly the problem is that you are testing for the value of
the file uploaded. Correct me if I'm wrong but I *think* that the value
of a file field, i.e. if($_FILE[pageimage]) will give you an empty value
but not a *null* value - so an empty value is still valid - this is why
it evaluates as true - the variable exists, it's just empty.
Here is a portion of a script I use for testing file uploads - i think
it will at least get you going in the right direction. I test on the
filename/type/sizes instead. Probably not the most graceful but works. ;-)
=====================
/* upload files */
$stamp = date("U");
$error = "false";
$uploadTemp = $_FILES['userfile']['tmp_name'];
if($uploadTemp != "") {
// test for images
if($_FILES['userfile']['type'] == "image/gif" ||
$_FILES['userfile']['type'] == "image/jpeg" ||
$_FILES['userfile']['type'] == "image/png") {
if($_FILES['userfile']['type'] == "image/gif") {
$ext = ".gif";
}
if($_FILES['userfile']['type'] == "image/jpeg") {
$ext = ".jpg";
}
if($_FILES['userfile']['type'] == "image/png") {
$ext = ".png";
}
$imagehw = GetImageSize($uploadTemp);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
if($imagewidth > "640" || $imageheight > "480") {
$error = "true";
$errorNo = 2;
}
if($error == "false") {
$uploadFileName = $stamp.$ext;
}
}
// else this is another type of file
else {
$error = "true";
$errorNo = 1;
}
}
else {
$uploadFileName = "";
}
if($error == "true") {
header("Location: somefile.php?error=$error&errorNo=$errorNo");
}
// now move the uploaded file
if($uploadFileName != "") {
$uploadFile = $filepath.$uploadFileName;
$upload = move_uploaded_file($_FILES['userfile']['tmp_name'],
$uploadFile);
}
===========================
HTH.
cc
Marian Briones wrote:
> Well, I latched onto the size value of the upload and figured okay, if
> the value is greater than 0, then process the file
>
> if ($_FILE['pageimage']['size']==0)
> {
> $processimage="no";
> $imageinsert="$oldimage";
> }
> else
> {
> $processimage="yes";
> }
>
> But guess what?
>
> IT STILL DOESN'T WORK! It won't even process the image now even
> though the size is greater than 0!
>
> I am stumped
>
> PS James, thank you for your great info here. This particular area
> is only available to site administrators with passwords.
>
> --- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote:
>> --- Marian Briones <[EMAIL PROTECTED]> wrote:
>>
>>> I posted yesterday and no one answered; I"m wondering if this
>>> list is having tech difficulties....
>>
>> Your message came through but perhaps people were busy. I know I
> was (and still am). However, to
>> briefly address your question I offer the following.
>>
>> Like $_POST and $_GET, $_FILES is a superglobal which is intended to
> collect information received
>> from a particular input stream. In this case, the $_FILES contains
> data relevant to uploaded
>> files.
>>
>> This associative array has a first key which corresponds to the name
> of the variable in your
>> upload form. In the example below, the name of the uploaded file is
> myfile so the portion of the
>> array is $_FILES['myfile'].
>>
>> <form method='post' action='script.php' enctype='multipart/form-data'>
>> <input type='file' name='myfile'>
>> <input type='submit'>
>> </form>
>>
>> You should make a test script with a simple form and in the PHP
> which is identified in the action
>> parameter of the form tag you can display the variables available
> during your upload:
>> <pre>
>> The $_FILES array contains:
>> <?php print_r($_FILES); ?>
>> </pre>
>>
>> When a file is uploaded you will see the following values:
>>
>> $_FILES['myfile']['name'] // name of the original file
>> $_FILES['myfile']['size'] // size in bytes of the file
>> $_FILES['myfile']['type'] // MIME type of the file
>> $_FILES['myfile']['tmp_name'] // path to temporary file
>> $_FILES['myfile']['error'] // error code (0=no error)
>>
>> You will have to consult one of these specific values to see if your
> file was uploaded. Keep in
>> mind that several of these values may not be trustworthy. For
> example, the MIME type could be
>> faked by the uploading computer so use a server-based verification
> that the item is really an
>> image (such as the getimagesize() function).
>>
>> File uploads are very risky if not handled carefully. You are
> basically allowing unknown web
>> users the ability to place files of any type on your server. Two
> newer functions were added to
>> PHP to help ensure that the data you think is a file was an actual
> upload:
>> http://www.php.net/is_uploaded_file
>> http://www.php.net/move_uploaded_file
>>
>> They should be used instead of the old copy() and unlink() method
> seen in old tutorials and
>> scripts on file uploads. There is also good information on:
>>
>> http://us3.php.net/manual/en/features.file-upload.php
>>
>> James
>> _____
>>
>>
>> James D. Keeline
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/