Can't figure out what is wrong

This is a program to allow an upload of a pdf file. The pdf file will be checked to see if it is a pdf, checked to make sure the file doesn’t exist. Then if all is well it is added to an array and a html document is generated based on all of the pdf files located on the server. I can’t figure out why this dosen’t work. When I trim the program down to the basics where a pdf can be uploaded, no checks are made, and the file is rewritten with php code without using an array but rather previous_contents of the file and then just adding the new file to the html document, the program works. When I add the extra features it wont work. Wont work means when I upload the file the result is a blank white page.

This code is where the user uploads the file(this is just a snippit, all the proper html tags do exist on the page:


  • Upload new bugle

  • Please choose a file:
    Make sure your file name is #.pdf. (Example: Bugle #71 should be named 71.pdf) After uploading you will be logged out [/code]

    Thank you.

    This is upload.php this is where the problem is


    <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']); //upload is passed from html submit forum $filename=$_FILES['uploaded']['name']; $checkpdf=substr($filename,-3);//string with file extension $counter = 0; $arr = array();
        if($checkpdf !== "pdf")
            echo ($checkpdf. " This is checkpdf variable n");
            echo ($filename." is not a PDF, please upload a pdf file. n");
        if($dir = opendir('./pdf'))
            while (false !== ($file = readdir($dir))) {
                    if ($file != "." && $file != "..") {
        if (array_search(substr($filename,0,-4),$arr))
            echo ($filename." already exists. Please try again.");
            exec('mv ./upload/* ./pdf/');
            $jpeg = ("/srv/www/htdocs/nuffle/bugle/pdf/thumbs/$myname.jpg"); 
            exec("convert -resize 200x258 ".$pdf."[0] ".$jpeg);//create thumbnail from pdf
            exec('cp /home/nuffle/static/html/league.html /home/nuffle/static/html/league_old.txt'); //back up, before overwriting
            foreach($arr as $myname)
                    mystring='<td><p align="center"><a href="' . $myname .'.pdf" target="_blank"><img src="' . $myname .'.jpg" width="200" height="258" alt="bugle' . $myname .'" /></p><h3 align="center">Bugle #' . $myname . ' </h3></a>';
                    $counter += 1;
                    if($counter == 4)
                            $mystring .="<br />";
                            $counter = 0;
            echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded <br />";
            echo ' <a href="#" onClick="history.go(-1)"></a><input type=button value="Back To the Upload Page" onClick="history.go(-1)">';
          //exec(`/home/nuffle/`); //refreshes python webserver
        //else { echo "Sorry, there was a problem uploading your file.n Please go back and try again. If the problem persists contact the webmaster n";
        //echo ' <a href="#" onClick="history.go(-1)"></a><input type=button value="Back" onClick="history.go(-1)">';

    I found the problem. I was missing a $ on mystring and I was missing a . to concatenate a variable to a string

    Sponsor our Newsletter | Privacy Policy | Terms of Service