PHP uploads a file and changes its name. who will help to modify the code under "accept Upload"? who will add the code for modifying the source file name at the time? thank you. If & nbsp; ($ _ SERVER ['request _ method'] & nbsp ;=& nbsp; 'post' & nbsp; & amp; & nbsp; isset ($ _ POST [the name of the PHP file to be uploaded. who can modify it?
The following code only accepts the upload. who will add a code that modifies the source file name at a time? thank you.
If ($ _ SERVER ['request _ method'] = 'post' & isset ($ _ POST ['sub '])
{
$ Myfile = $ _ FILES ["myfile"];
$ MyfileType = substr ($ myfile ['name'], strrpos ($ myfile ['name'], ".") + 1 );
If ($ myfile ['size']> $ maxSize)
{
$ Result = 1;
}
Else if (! In_array ($ myfileType, $ fileTypes ))
{
$ Result = 2;
}
Elseif (is_uploaded_file ($ myfile ['tmp _ name'])
{
$ ToFile = $ uploadDir. '/'. $ myfile ['name'];
If (@ move_uploaded_file ($ myfile ['tmp _ name'], $ toFile )){
{
$ Result = 0;
}
Else
{
$ Result =-1;
}
}
Else
{
$ Result = 1;
}
}
?>
------ Solution --------------------
$ ToFile = $ uploadDir. '/'. $ myfile ['name'];
This is the target file name
Just change it.
------ Solution --------------------
Reference:
$ ToFile = $ uploadDir. '/'. $ myfile ['name'];
This is the target file name
Just change it.
$ Date = date ('ymdhis ', time ());
$ ToFile = $ uploadDir. '/'. $ date. $ myfile ['name'];
Good guys do it to the end