Jump to content

How do I check if the $_FILES isset? Doesn't seem to work how I have it...


suttercain

Recommended Posts

Hi guys,

 

I have a form that allows five photo uploads at once. The thing is when the user uploads only one photo that should be it... but it still tries to upload and move the other, non existent photos. I have an if statement that does not seem to be working.... here it is:

 

<?php
//IF THERE IS A FIFTH PICTURE
if (isset($_FILES['articlePicFive']) || $_FILES['articlePicFive'] != NULL || $_FILES['articlePicFive'] != '') {
$imageName = $gathered['articleId'];
// PROCESS IMAGE
$target_path = "../images/articles/";
$target_path = $target_path . basename( $_FILES['articlePicFive']['tmp_name']); 
$_FILES['articlePicFive']['tmp_name'];

//MOVE THE IMAGE TO THUMBNAILS
move_uploaded_file($_FILES['articlePicFive']['tmp_name'], $target_path);

//EXPLODE TO RENAME IMAGE
$fileName = $_FILES['articlePicFive']['name'];
$broken = explode(".", $fileName);
rename("../images/articles/".basename($_FILES['articlePicFive']['tmp_name'])."", "../images/articles/".$imageName."_05." .$broken[1]."");

$update = mysql_query("UPDATE articles SET articlePicFive='" .$imageName."_05." .$broken[1]. "' WHERE articleId='".$imageName."'"		) or die(mysql_error());
}
?>

 

What am I doing wrong? See if statement at the start... even though the form fiels is empty it is treating it as there is a file...

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.