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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post 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?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

oooo this might work...

$pic=($_FILES['avatar']['name']);
echo "$pic";
It produces the filename.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

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

Post by McInfo »

I can't think of a reason an application should not be able to handle spaces in file names.
Post Reply