search

Home  >  Q&A  >  body text

There is an error reported in $name and I don’t know the reason.

$name I didn’t follow the example. What I wrote was $name=date('Y-m-d h:i:s').".".Tail variable

Then it prompted failed to open stream: Invalid argument in, if I remove the date, it will be fine. What did I do wrong?

❤非酋❤非酋2657 days ago1678

reply all(4)I'll reply

  • 逸先生

    逸先生2017-08-24 10:35:07

    代码没问题,应该是目标路径的问题,更改一下路径或者添加./试一试

    reply
    0
  • PHP中文网

    PHP中文网2017-08-23 11:50:16

    Post the error message. rand(0,10).'.'.$lastimg; The code here is wrong. Change it to rand(0,10).$lastimg;

    Reply


    reply
    0
  • ❤非酋

    $lastimg actually equals jpg, so there is definitely no problem with the . in the middle. There is a problem just because the previous date is added.

    ❤非酋 · 2017-08-23 15:08:30
    ❤非酋

    Warning: move_uploaded_file(upload/images/2017-08-23 15:09:066.jpg): failed to open stream: Invalid argument in D:phpStudyWWWfile.php on line 40 Warning: move_uploaded_file(): Unable to move 'C:UsersAdministratorAppDataLocalTempphp2872.tmp' to 'upload/images/2017-08-23 15:09:066.jpg' in D:phpStudyWWWfile.php on line 40 上传失败 这是报错信息

    ❤非酋 · 2017-08-23 15:09:47
  • ringa_lee

    ringa_lee2017-08-23 11:40:10

    What you are reporting is an error in the parameters of the date function

    reply
    0
  • ❤非酋

    But what's wrong with date? There is no problem if I output this date ('Y-m-d H:i:s') alone~

    ❤非酋 · 2017-08-23 15:11:00
    ❤非酋

    But what's wrong with date? There is no problem if I output this date ('Y-m-d H:i:s') alone~

    ❤非酋 · 2017-08-23 15:11:02
    ❤非酋

    But what's wrong with date? There is no problem if I output this date ('Y-m-d H:i:s') alone~

    ❤非酋 · 2017-08-23 15:11:03
    ringa_lee

    Do important things need to be said three times? --! Then take a look at your entire code post. If this is correct, then it must be the mistake behind it.

    ringa_lee · 2017-08-23 16:32:22
  • 天蓬老师

    天蓬老师2017-08-22 17:26:32

    date('Y-m-d H:i:s), pay attention to capitalization

    reply
    1
  • ❤非酋

    I modified it as you said, but it still doesn't work. These are a few lines of code. Lastimg is the original one. There is no problem with this. $name=date('Y-m-d H:i:s').rand(0,10).'.'.$lastimg; if (is_uploaded_file($_FILES['file']['tmp_name'])) { if (move_uploaded_file($_FILES['file']['tmp_name'], $path .$name)) {

    ❤非酋 · 2017-08-23 10:25:18
    ❤非酋

    $name=date('Y-m-d H:i:s').rand(0,10).'.'.$lastimg; if (is_uploaded_file($_FILES['file']['tmp_name'])) { if (move_uploaded_file($_FILES['file']['tmp_name'], $path .$name)) {

    ❤非酋 · 2017-08-23 10:25:51
    PHP中文网

    Post the error message. rand(0,10).'.'.$lastimg; The code here is wrong. Change it to rand(0,10).$lastimg;

    PHP中文网 · 2017-08-23 11:50:00
  • Cancelreply