The rename file is incorrect.

Source: Internet
Author: User
A strange problem is that the rename file is incorrect. please refer to the code below:
$ Uploadfile = $ uploaddir. basename ($ _ FILES ['music'] ['name']);
$ Musicname = basename ($ _ FILES ['music'] ['name']);

If (move_uploaded_file ($ _ FILES ['music'] ['tmp _ name'], $ uploadfile )){

$ Md5string = md5_file ($ uploadfile );
If (stripos ($ uploadfile, ". mp3 ")! = False)
{
$ Filename2 = "/data/www/html/song/upload/m /". $ subdir. "/". $ userid. "/". $ userid. "_". $ md5string. ". mp3 ";
If (file_exists ($ filename2 ))
{
Unlink ($ uploadfile );
}
Else
{
If (rename ($ uploadfile, $ filename2 ))
{
}
Else
{
}
}
}
The error file on the server is as follows (more ~) :


Have you ever encountered a similar problem?


Reply to discussion (solution)

Why is the name not directly named in the second parameter of move_uploaded_file? Instead, you have to rename it after the upload is successful?

Because after the file is uploaded to the server, calculate the md5 value and rename it

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.