0

I have some code that needs to see if a file has been selected before it runs the code .... its pretty simple code, its just not working for some reason and i cant see why. my code is as follows

if(isset($_FILES['filename'])){
$directory = 'uploads/'.substr(md5(microtime() * mktime()),0,15);

if(!is_dir($directory)){
    mkdir($directory, 0777, TRUE);
    chmod($directory, 0777);
}

}

I have multiple file fields which are coded like so:

<input class="file-input" name="filename[]" type="file" size="32" />

When i move the code OUTSIDE the 'if(isset......' block, it works perfect .... just not inside it, and thats where i need it.

Can anyone see where im going wrong?

1
  • 1
    microtime() * mktime() makes no sense. You are multiplying a string (yes, microtime returns a string unless you use microtime(true)) with a number. md5(microtime()) should be good enough for your purpose. Or have a look at uniqid Commented Dec 2, 2010 at 16:50

1 Answer 1

1

Oh dear .... I figured the problem.

Yes thats right folks .... I forgot to change the type of form to multipart.

Feel free to throw things at me!!!

Thanks anyways guys!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.