Page 1 of 1

File upload from mac shows no filename

Posted: Sun Jun 06, 2010 11:03 pm
by dpmiller
I am growing bald because I am pulling my hair out on this one!

I am uploading a file from Flash using a FileReference object to the below php file:

Code: Select all

session_start();
//$fileID=060620101856121; Saves file as 12787777.jpg
//$fileID="060620101856121"; Saves file as 060620101856121.jpg which should be correct with the session variable
$fileID=$_SESSION['fileID']; //Saves file as .jpg with out the file name
$newname=$fileID.".jpg";
$path="images/".$newname;
move_uploaded_file($_FILES['Filedata']['tmp_name'], $path);
echo "&upload_msg=".$path."&fileID=".$fileID."&"; //this echos the correct information
The above works just fine on my pc but on my mac it behaves as my comments in my above code.

Does anyone have a clue as to why this works on the pc but not the mac?

Any help would be much appreciated. :banghead:

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 4:05 am
by markusn00b
It seems to be caused by the leading 0. Unsure why, though. Going to investigate.

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 4:08 am
by markusn00b
Literal numbers starting with 0 are treated as octal. So cast your number to the appropriate type, or use quotes. Simples.

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 12:05 pm
by dpmiller
It turns out it is not a leading zero issue. It just won't use the session variable. I hard coded the session variable to be "goober" and after retrieving the session variable I added a prefix of "xx". Now it saves the file as xx.jpg. Somehow it is ignoring the session variable value when it saves the file. What is crazy is that the echo statement outputs the correct info: xxgoober.jpg :?

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 12:21 pm
by dpmiller
What I also don't understand is why it works on a pc and not a mac. It is all server-side processing. How can it differ by getting information from a pc vs. a mac?

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 12:23 pm
by Jonah Bron
Could it be that you have cookies disabled on the Mac?

Re: File upload from mac shows no filename

Posted: Mon Jun 07, 2010 1:59 pm
by dpmiller
Thanks for the reply but my cookies are enabled for sites I visit.

I did find a solution/workaround. I created a simple php file to retrieve the session variable and echo it so that flash can retrieve it. The flash file gets the variable and when calling upload I append the url with the session variable. The php file that moves the file upload then retrieves the variable via _GET and uses it as the filename. Works just fine for both pc and mac.