File upload from mac shows no filename

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
dpmiller
Forum Newbie
Posts: 6
Joined: Tue May 25, 2010 7:54 pm

File upload from mac shows no filename

Post 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:
Last edited by Benjamin on Mon Jun 07, 2010 7:45 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: File upload from mac shows no filename

Post by markusn00b »

It seems to be caused by the leading 0. Unsure why, though. Going to investigate.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: File upload from mac shows no filename

Post by markusn00b »

Literal numbers starting with 0 are treated as octal. So cast your number to the appropriate type, or use quotes. Simples.
dpmiller
Forum Newbie
Posts: 6
Joined: Tue May 25, 2010 7:54 pm

Re: File upload from mac shows no filename

Post 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 :?
dpmiller
Forum Newbie
Posts: 6
Joined: Tue May 25, 2010 7:54 pm

Re: File upload from mac shows no filename

Post 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?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: File upload from mac shows no filename

Post by Jonah Bron »

Could it be that you have cookies disabled on the Mac?
dpmiller
Forum Newbie
Posts: 6
Joined: Tue May 25, 2010 7:54 pm

Re: File upload from mac shows no filename

Post 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.
Post Reply