简体   繁体   中英

Doesn't work move_uploaded_file

I'm trying to upload one picture to 2 places. It only works first move_uploaded_file

<?php
    echo move_uploaded_file($_FILES['portada_file']['tmp_name'],'img/portada/170x243/zzzzz.jpg').'<br>';
    echo move_uploaded_file($_FILES['portada_file']['tmp_name'],'img/portada/170x243/zzzzz.jpg').'<br>';
?>
<form action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
    <input type="file" name="portada_file" id="form_portada_file" value="<?php echo @$_POST['portada_file']; ?>"/>
    <button name="serie" type="submit" class="no_margin_left">Enviar</button>
</form>

Answer:

1
0

Based on the OP's comment:

It's true, thank you so much. You cannot move the file again, because it has already been moved. It no longer exists for the second move.

Once moved you can copy the moved file n to a new location using PHP's copy() function, for example:

copy('img/portada/170x243/zzzzz.jpg', 'img/static/zzzzz.jpg')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM