file_exists ?

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

mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

yep
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

do i need to put one in the upload folder too?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Nope, should only need it in the dir where the form is, and possible the dir where the file that does the move_uploaded_file stuff is.
Your host may not allow you to override the upload size. One other solution is to remove the <INPUT TYPE="hidden" name="MAX_FILE_SIZE" lines from the form and just use your hosts 8M limit *shrug*
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

So how come i can put things that are less than 2 but not what my php.ini (8mb) is set at?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Your <INPUT TYPE="hidden" name="MAX_FILE_SIZE" .. appear to be overriding it somehow. I didn't think putting 2 of them in the same form would work, and it doesn't :o So you may have to leave the hidden fields out and handle the allowed sizes in code using the size property of the $_FILES array.
Eg if($_FILES['mp3file']['size'] > 6000000){ ... } etc..same for the image file
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

I could change my php.ini to say 6 mb... So would i still have to do that if statement if i changed my phpini to 6mb upload max and removed the hidden fields?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Nope, wouldn't need those fields, that would allow 6M images and mp3 files. As it stands, if you remove those hidden fields it should allow 8M images and mp3 files.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i dont think im understanding this clearly.. So even if i do what i just stated the mp3 files will still have to be under 2 mb?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

No, basically, if you remove those 2 hidden fields then both images and mp3's will be limited to 8M (the value in your php.ini).

Just try removing them first and see if you can upload an mp3 that's larger than 2M, it should let you now.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

ooooo So what would my code look like if i did that if statement?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Same as the form is now, just remove those 2 hidden MAX_UPLOAD fields.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i mean the upload script
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

oh, you mean if you want to use the 8M size limit but set a limit in the code?
Then you could just do something like :
$imglimit = 200000; //200K
$mp3limit = 6000000; //6M
if($_FILES['imagefile']['size'] > $imglimit){
echo 'Image is too big'; exit;
}
if($_FILES['mp3file']['size'] > $mp3limit){
echo 'Mp3 is too big'; exit;
}

Just put that anywhere before all the file_exists stuff.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

Thanks once again Mark
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i still get that error i originally got...
Post Reply