PHP mp3 upload with spaces in filename
I am building a site, where users can up开发者_如何学编程load their mp3s and I ran into a little problem that I can't solve:
The upload works fine, but only when the user selects an mp3-file which has no spaces in their mp3-filename. A file like 'My nice mp3 file.mp3' will result in a NULL of $_FILES['file']. Has this to do with Server-configurations?
Anyone has an idea how to solve that? Other than telling the user just to upload mp3files without spaces in their names, that is :-)
Thanx,
Maenny
As the other users have said, it's probably not the spaces causing the problem. My first thought would be to check that your upload_limit for PHP is set high enough. Remember also that no matter what the user has called their file, you should NEVER store it with that filename on the server - there's too much risk of a potential security hole by doing that.
To diagnose this problem though, I'd suggest creating an MP3 file that you know is OK, make 2 copies - name one with spaces, and one without. And then see whether the one with spaces fails. If that is the case, then at least you know that you've definitely found the source of your problem - if not, then you've eliminated one possible cause of it, and you can look elsewhere.
The filename of the remote (client) file should not affect how it is transported to the server. Are you sure that spaces are the problem?
Try to urlencode() your file name.
If that doesn't work, try rawurlencode().
If that doesn't work, I am off mark :)
Spaces should not cause this issue. I have an MP3 uploader on my website and have no trouble with spaces. I have tested with "Test Name.mp3" and it worked fine.
http://www.the-mag.me.uk/Music/Articles/Item/Add-Your-Music/
To help you diagnose any potential problem, try dumping out the contents of the $_FILES array and check to see if anything in there gives you a clue.
print_r($_FILES);
精彩评论