Upon uploading a file from my web page, the dialog appears "No upload", after the file uploads successfully. Any help with showing the correct message is appreciated. (and any other guidance).

<?php
foreach (array('video', 'audio') as $type) {
    if (isset($_FILES["${type}-blob"])) {

        $fileName = $_POST["${type}-filename"];

       $uploadDirectory = 'uploads/' . $fileName;

            // make sure that one can upload only allowed audio/video files
            $allowed = array(
                'webm',
                'wav',
                'mp4',
                'mov'
    );

    $extension = pathinfo($uploadDirectory, PATHINFO_EXTENSION);
    if (!$extension || empty($extension) || !in_array($extension, $allowed)) {
        echo 'Invalid file extension: '.$extension;
        return;
    }

$new_filepath = "uploads/" . uniqid() . ".". $extension;

if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $new_filepath)) {

         echo (" problem moving uploaded file");
       }

if(!file_exists($_FILES["${type}-blob"]["tmp_name"]) || !is_uploaded_file($_FILES["${type}-blob"]["tmp_name"])) {
    echo 'No upload';
}
    }
}
?>

and here's the corresponding js:

`
function uploadFile() {
// create FormData
var fileType = 'video'; // or "audio"
var fileName = 'vid.webm';
var formData = new FormData();
var request = new XMLHttpRequest;
formData.append(fileType + '-filename', fileName);
formData.append(fileType + '-blob', blob);
request.open("POST", "/save1.php");

     request.onreadystatechange = function() {
	 if(request.readyState==4) {
	 alert(request.responseText);
	 }
	}

        request.send(formData);
   }

`

    Looks like that's because you've already done the move_uploaded_file() at that point. You should probably put that if block before you do the move, maybe inverting it a bit to something like:

    if(file_exists($_FILES["${type}-blob"]["tmp_name"]) && is_uploaded_file($_FILES["${type}-blob"]["tmp_name"])) {
        if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $new_filepath)) {
             echo (" problem moving uploaded file");
        }
    } else {
        echo 'No upload';
    }
    

      You might also need to make sure the form you create has the right enctype attribute of multipart/form-data. If it's not, you won't get any files uploaded. See the docs.

        Many thanks for your reply/help. I have this now:

        if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $new_filepath))
        {
        echo 'No Upload';
        } else {
        echo 'File Uploaded';
        }

        Can you suggest a simple, more interesting way to display the standard "File Uploaded" after upload?
        I saw this js I'd like to test, but I don't know how to connect it to the the current successful upload code:

        `var janelaPopUp = new Object();
        janelaPopUp.abre = function(id, classes, titulo, corpo, functionCancelar, functionEnviar, textoCancelar, textoEnviar){
        var cancelar = (textoCancelar !== undefined)? textoCancelar: 'Cancel';
        var enviar = (textoEnviar !== undefined)? textoEnviar: 'Send';
        classes += ' ';
        var classArray = classes.split(' ');
        classes = '';
        classesFundo = '';
        var classBot = '';
        $.each(classArray, function(index, value){
        switch(value){
        case 'alert' : classBot += ' alert '; break;
        case 'blue' : classesFundo += this + ' ';
        case 'green' : classesFundo += this + ' ';
        case 'red' : classesFundo += this + ' ';
        case 'white': classesFundo += this + ' ';
        case 'orange': classesFundo += this + ' ';
        case 'purple': classesFundo += this + ' ';
        default : classes += this + ' '; break;
        }
        });
        var popFundo = '<div id="popFundo' + id + '" class="popUpFundo ' + classesFundo + '"></div>'
        var janela = '<div id="' + id + '" class="popUp ' + classes + '"><h1>' + titulo + "</h1><div><span>" + corpo + "</span></div><button class='puCancelar " + classBot + "' id='" + id +"
        cancelar' data-parent=" + id + ">" + cancelar + "</button><button class='puEnviar " + classBot + "' data-parent=" + id + " id='" + id +"_enviar'>" + enviar + "</button></div>";
        $("window, body").css('overflow', 'hidden');


        $("body").append(popFundo);
        $("body").append(janela);
        $("body").append(popFundo);
         //alert(janela);
        $("#popFundo_" + id).fadeIn("fast");
        $("#" + id).addClass("popUpEntrada");
        
        $("#" + id + '_cancelar').on("click", function(){
            if((functionCancelar !== undefined) && (functionCancelar !== '')){
                functionCancelar();
                
            }else{
                janelaPopUp.fecha(id);
            }
        });
        $("#" + id + '_enviar').on("click", function(){
            if((functionEnviar !== undefined) && (functionEnviar !== '')){
                functionEnviar();
            }else{
                janelaPopUp.fecha(id);
            }
        });

        };
        janelaPopUp.fecha = function(id){
        if(id !== undefined){
        $("#" + id).removeClass("popUpEntrada").addClass("popUpSaida");


                $("#popFundo_" + id).fadeOut(1000, function(){
                    $("#popFundo_" + id).remove();
                    $("#" + $(this).attr("id") + ", #" + id).remove();
                    if (!($(".popUp")[0])){
                        $("window, body").css('overflow', 'auto');
                    }
                });
                
          
        }
        else{
            $(".popUp").removeClass("popUpEntrada").addClass("popUpSaida"); 
            
                $(".popUpFundo").fadeOut(1000, function(){
                    $(".popUpFundo").remove();
                    $(".popUp").remove();
                    $("window, body").css('overflow', 'auto');
                });
                
           
        }

        }
        $("button").on("click", function(){
        var myText = $("#myText").val();
        janelaPopUp.abre( "asdf", $("#size").val() + " " + $(this).html() + ' ' + $("#mode").val(), $("#title").val() , myText)
        });
        janelaPopUp.abre( "example", 'p red', 'Example' , 'chosse a configuration and click the color!');
        setTimeout(function(){janelaPopUp.fecha('example');}, 2000);`

          Write a Reply...