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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.