Page 1 of 1

Can I query the uploaded file - BEFORE it is uploaded?

Posted: Wed May 11, 2011 5:08 am
by simonmlewis

Code: Select all

$uploadedfile = $_FILES['avatar']['tmp_name'];
This is what is passed thru from the form, via

Code: Select all

<input type='file' name='avatar'>
Some people are uploading them with spaces and it is causing problems elsewhere in my code.
So I want to stop them and suggest them remove spacing.

I know how to query it for spacing, via pregmatch or preg_replace, but how do I query the variable itself?
I can't query $uploadedfile, or $avatar.

How do I do it?

Re: Can I query the uploaded file - BEFORE it is uploaded?

Posted: Wed May 11, 2011 5:10 am
by simonmlewis
oooo this might work...

$pic=($_FILES['avatar']['name']);
echo "$pic";
It produces the filename.

Re: Can I query the uploaded file - BEFORE it is uploaded?

Posted: Wed May 11, 2011 3:02 pm
by McInfo
I can't think of a reason an application should not be able to handle spaces in file names.