How to return to the previous page after uploading a photo (without losing the data)

1

I am complicating myself with something that I think will be simple but my inexperience makes me bogged down.
I have a page where I upload a news, it is very simple, so simple that I can upload a single photo.

<form action="subir.php" method="POST" enctype="multipart/form-data">
                <div class="ui segment">
                    <input type="text" name="archivo_final" value="<?php echo $proxima; ?>" hidden> 
                    <input class="ui button" type="file" name="imagen" id="imagen">
                    <input  type="text" name="nombre_peli">
                    <input class="ui blue button" type="submit" name="subir" value="Subir imagen">
                </div>
            </form>

the UP button has that code. Now, in the file subir.php when the upload of the file to the server occurs, I put this code:

if (!file_exists($ruta)){
   $resultado = @move_uploaded_file($_FILES["imagen"]["tmp_name"], $ruta);
   if ($resultado){
      header('Location: nueva_noticia.php');
      //echo "El archivo se ha movido exitosamente.";
   } else {
      echo "Ocurrió un error al mover el archivo.";
 }
 } else {
   echo $_FILES['imagen']['name'] . ", este archivo existe";
 }

The problem I have is that when everything goes perfect, that "header" returns me to the previous page, but if I already had the news loaded, I deleted everything, it's like loading everything from scratch ... I do not know if it suits me to create a php function and return the result of the function ...

PS: before I had a phpupload plugin that I found out there but I do not want to add more extra things that end up making the project more complex. It is more, I use semantic and there is no way to put a button to upload an image that is neat ...

    
asked by MNibor 12.08.2017 в 19:15
source

1 answer

1

good friend the thing is simple for what you are looking for that I understood you could do something simple like:

    
answered by 15.08.2017 / 07:04
source