If you use PHP to change the MD5 value of the uploaded file and keep the suffix

Source: Internet
Author: User
Assume that I use php to receive files uploaded in the form. How can I rename the uploaded file (change it to its md5 value to prevent duplicate names) and retain the suffix. It is best to give a sample code that assumes that I use php to receive files uploaded in the form, How can I change the name of the uploaded file (change it to its md5 value to prevent duplicate names), and retain the suffix.
It is better to give a sample code

Reply content:

Assume that I use php to receive files uploaded in the form. How can I rename the uploaded file (change it to its md5 value to prevent duplicate names) and retain the suffix.
It is better to give a sample code

Assume that the form is as follows:



  

In this way, you can change the name:
$ Str = 'test. name ';
$ Pos = strrpos ($ str ,'.');
Echo substr_replace ($ str, md5 (substr ($ str, 0, $ pos), 0, $ pos );
It's hard to write code on a mobile phone...

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.