Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by phppup

  1. I already have a working PHP/HTML uploading form that I've been working on and tweaking as a single PHP file.

    Now, I am attempting to integrate a progress bar.

    It seems almost impossible to find a working script to show the progress of multiple files as they upload.  However, I have one that is "good enough" and have broken it down thusfar so that I can effectively integrate it into my working script.

    At this point, (aide from the JQuery, CSS, etc.) it consists primarily of two files: The first is a PHP file containing the form and basic links for function and style.

    The second is a PHP upload file that is handling the "heavy lifting."  I have broken it down to this:

    $dir = 'uploads/';
    $count = 0;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' and isset($_FILES['files']))
      // loop all files
      foreach ( $_FILES['files']['name'] as $i => $name )
        // now we can move uploaded files
          if( move_uploaded_file($_FILES["files"]["tmp_name"][$i], $dir . $name) )
      echo json_encode(array('count' => $count));

    No names or file locations have been changed and it functions as originally designed in this condition.  However, if I combine the first file with this file, I loose the  

    echo json_encode(array('count' => $count));

    result, which is expanded in another file to be a final message of "You have uploaded $count files successfully."

    What am I doing wrong or missing?  Is there an easier way to do this?  A link to a fancy progress bar for multiple file upload would be wonderful, as most that I've found actually do not work.

  2. I have an index HTML form that has a JavaScript link and action = 'xyz.php' 

    Everything works fine. 

    I've seen PHP scripts with HTML form after the closing tag ?> and they work.

    Yet when I included my HTML g form after my PHP code, some of my JS stopped working.

    What are the protocols to combining PHP and HTML?

    Which should run first?

    When is the action run?


  3. Thanks greatly to cyberRobot. 

    Using the diagnostic PRINT line assured me that the UPLOAD is being grabbed and effectively moving files.

    Now I need to focus on the code.  At this point, I think these lines are where my problem lies

    if($dir = opendir($startingFolder)){
    	while(($file = readdir($dir))!== false){

    The original scripting (which works) is designed to take folders from an established folder rather than from an upload.  So my thinking is that I need to initiate a transition.  I have tried replacing these lines with

    foreach ($_FILES["upload"]["error"] as $key => $error)
           $tmp_name = $_FILES["upload"]["tmp_name"][$key];
           if (!$tmp_name) continue;
           $name = basename($_FILES["upload"]["name"][$key]);
        if ($error == UPLOAD_ERR_OK)

    but that is apparently incorrect.

    What coding can I use to bridge the gap to allow the uploaded files to continue through the scripted process?


  4. I am double checking my code and I have had the correct syntax in place (ie: $startingFolder = $_FILES['upload']; )  yet I am not getting a result unless a switch back to $startingFolder = 'myLocalstorage/';  (at which point everything runs fine.

    Is there a diagnostic or echo that I can use to confirm a connection to the uploading items.

    My upload is confirming that the items are selected, but I am not receiving a success message nor am I seeing a result in my destination folder when I upload.


  5. In actuality the quotes are in the correct location.

    It's the damn software that I am trying to use to create the post that keeps shifting things.

    $startingFolder = $_FILE['upload'];


    But I still am not getting any results.

    PS: should echo $startingFolder give me the name of the tmp folder or list its contents?

    What do I need to complete the connection?



    yez, I h@te it soooo much.


  6. Thanks to all, but I am still confused.

    I have read both Barand's references earlier, and in fact have quotes on my array index.

    Am I correct in expecting

    $startingFolder = '$_FILE['upload'];

    to work as a valid replacement to

    $startingFolder = 'LocalFolder/'

    or am I missing something.

    Isn't the code that effectively loops through the folder's files adequate to loop through the array?

    Should I be linking to the tmp folder instead?

  7. I have a PHP script that modifies images that are stored in a local folder related to $startingFolder.

    Essentially, I can use
     $startingFolder = 'anyFolder/';
     $finalFolder = 'endResult/';

    To manage the variables and direct the source and destination of the scripts actions from this starting point.

    I'm trying to extend my capabilities so that I can use the script while uploading images.

    Rather than UPLOAD several images to  $startingFolder and then run the script, I thought it would be more efficient to handle this in one script.

    However, I am having trouble making the CONNECTION so that this can be accomplished.

    What is the proper way to 'grab' the files during upload?  How can I access the files during the process?

    I have a working HTML
    <input type='file' name='upload[]' multiple >

    And have tried
     $startingFolder = '$_FILE[upload]';
    but I am missing the mark somewhere.
    Please help.


  8. After a lot of reading and some progress, there are now a whole new set of questions that have emerged.

    So this thread requires more discussion and opinion for guidance, rather than actual code solutions.

    I have found different approaches to uploading image files. Some upload directly to a destination folder. Some upload to a database. Some do both.

    It seems more practical to upload image files to a folder (although I do recognize the bonus of having information about the individual files stored for reference), but is there a benefit to using one instead of the other? For space? Speed? Other implementations?

  9. An obvious answer would be ok. Sometimes the most difficult solutions are in plain sight.

    I am not doing the images in a database, so I am looking at JS scripting.

    I want sure if the destination folder is required to be at the top of a script, or file some specific guidelines.

    I'm sure I'll eventually find the answer, but I was hoping for a clue that might help me save some time.


  10. It always seems so simple.... LOL

    Hello to my old friends,

    I have been toying with adding an UPLOAD SCRIPT for moving images from a desktop to a website in order to eliminate the need to log into the server to post images.

    I've seen a few online scripts of various degrees and some with demos), yet the one blaring question remains: Where is the line that dictates where the files end up?

    So many of the scripts explain how wonderfully they look and operate, but they do not indicate where to edit in order to control the endpoint.

    Any insight, as well as guidance to avoid pitfalls with regard to this venture will be appreciated.

    Happy Halloween, as if coding isn't scary enough (at times).  *wink*



  11. To Barand, I see.  It appears to be required because of mysqli_real_escape_string .  Since my code is ONLY being tested locally, I have been negligent with security and focused on functionality.

    I suppose when I go live I will want to utilize the mysqli_real_escape_string  with the proper connectivity.

    I'm a bit surprised that this needs to be done individually for each variable.  Is there a method to simply address "ALL VARIABLES" somehow?

    PS: Glad that was my only faux pas in my post.  ALWAYS LEARNING.

  12. Also, you have EMAIL and SERIAL NO. as UNIQUE keys.  From a novice standpoint, I found this to be difficult for testing.

    Again, I would re-create the table with the SIMPLEST standards and seek success.  Then, re-develop and grow so that you can control your experimentation and understand hardships as you overcome them.  This helped me learn and develop.

  13. There are many more qualified than me to debug your code, but I recognize your format.

    Double check everything with a fine tooth comb.  A single semi-colon or comma can ruin all your work and make you crazy.

    Look at the MySQL database and confirm that the database name and table name are spelled EXACTLY identically to what you have in your scripting.

    I also don't know that you need $con in these lines

    $fullname = mysqli_real_escape_string($con, $_POST['fullname']);
    $company = mysqli_real_escape_string($con, $_POST['company']);
    $email = mysqli_real_escape_string($con, $_POST['email']);
    $serial_no = mysqli_real_escape_string($con, $_POST['serial_no']);

    the redundancy may be causing an issue.  I would try

    $fullname = mysqli_real_escape_string($_POST['fullname']);
    $company = mysqli_real_escape_string($_POST['company']);
    $email = mysqli_real_escape_string($_POST['email']);
    $serial_no = mysqli_real_escape_string($_POST['serial_no']);

    If all else fails, I have found it useful to remove lines of code to establish a single successful effort.

    Eliminate company, email, and serial_no and SIMPLY work with getting a SUCCESSFUL insertion of $fullname.  Then, build from there (to ensure that no single variable is destroying your entire effort.)


  14. Is there a recommended BEST PRACTICE for storing (and retrieving) telephone numbers from a database table?

    Is it best to store (in the USA) the area code separate from the rest of the number?  Remove parenthesis and/or dashes? 

    Or is there no reason to concern myself with performance or hacking issues regarding the storage of phone numbers as 323-555-1212 or (323)555-1212 inside my table?

  15. I want to use a particular input for telephone numbers.

    I have seen working examples, and either need to edit or create code for my end result 

    Aside from the usual telephone number mask, this input field dynamically replaces the value/placeholder that is visible.

    To elaborate, the user sees the input text box with (___)___-____ displayed.

    As digits are entered, the field replaces underscores with digits in a progression until complete.

    (21_)___-____ , next (212)55_-____, then (212)555-12__ until finally (212)555-1212

    Any direction would be helpful.

  16. ginerjm: I appreciate the input, but that still does not address the problem I am currently experiencing.

    Currently, with a single IF statement

    if($a = 'one'){
    $variable = "POOR";  }    //single EQUAL sign [which CHANGES the value of $a]

    The result of

    echo "Your score was $variable "     //result is:    Your score was POOR



    if($a == 'one'){
    $variable = "POOR";  }    //double EQUAL sign [which COMPARES the value of $a while echo $a displays:   one  ]

    The result of

    echo "Your score was $variable "     //result is:    Your score was

    Thus, the $variable is not being 'grabbed' or the comparison is somehow failing.


  17. $selected_value_1 is passed from a form as INPUT with a value of either 'one', 'two', 'three', 'four'

    $a = $selected_value_1;        // in scripting

    which brings me back to

    if($a == 'one'){
    $variable = "POOR";}
    if($a == 'two'){
    $variable = "GOOD";}
    if($a == 'three'){
    $variable = "VERY GOOD";}
    if($a == 'four'){
    $variable = "EXCELLENT" ;}

    echo $variable  //used later on



    echo " $a ";

    Results either one, two, three, four (depending on which input I select).

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.