tags:

views:

39

answers:

1

I have a pretty standard file upload form (that is also writing to a mysql db). It was working fine throughout my testing, then I went and tested a file that was named with all capital letters. The file would not upload. Simple solution I figured, just rename the file before the upload with 'strtolower' but no luck. Also tried strtoupper, still no luck. I think I'm also running into this issue with files starting with numbers. (i did double check and yes the folder is writable.)

$upload_dir = "/path/to/the/upload/folder/entries/";
$new_filename = mysql_insert_id()."_".$filename;
$tmp_name = $_FILES["filename"]["tmp_name"];
move_uploaded_file($tmp_name, $upload_dir . $new_filename);

any help is GREATLY appreciated.

+1  A: 

Need to isolate the step where the error is happening--what do you mean specifically, "the file will not upload"? Does no file get to the server? Does the rename not work? Is the mysql statement doing the insert not formed correctly? If the file never gets to the server, then you have nothing on which to invoke strtolower.

Take a known, working, uploadable file, upload it to be sure it works, then rename it to its uppercase version and try again. If picture.jpg works, does PICTURE.JPG? Or PICTURE.jpg? I'm wondering if there's something in the previous parts of your code that is deciding ".JPG" (or whatever capitalized extension) isn't a valid upload like ".jpg" is.

spinn
spinn,good call on renaming the file to test.so here's where i'm at...basically it appears that sometimes image files are not being detected as such. the jpg file i was trying to test (that was failing), was pulled directly from my iPhone. despite it showing up as a type jpeg in my Finder, when i try to grab the ["type"] (for both writing to the db and general file upload error check), it returns nothing. so i guess what i need is some way to guarantee these 'images' to go through. any thoughts?
jmarx34
Just too many variables here...I'm not really clear where the upload is actually failing. Is there anything at all in the $_FILES array, or is it just the type that's missing?
spinn