#16
  1. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,961
    Rep Power
    4575
    You have a typo on line 3.
    -- Cigars, whiskey and wild, wild women. --
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    Normally I'd be quite amazed that someone could use the right variable in one area and a completely different variable in another area, but I know you copy and paste **** and have no clue what's going on. So I'm not.
    Originally Posted by Sepodati
    Normally I'd be quite amazed that someone could use the right variable in one area and a completely different variable in another area, but I know you copy and paste **** and have no clue what's going on. So I'm not.
    Look at line 80:
    PHP Code:
    $id_verification_video_file trim($_POST["id_verification_video_file"]); 
    Has not the variable been set ?
    This will show error:
    PHP Code:
    $id_verification_video_file "trim($_POST["id_verification_video_file"])"
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    You have a typo on line 3.
    My line 3 looks like this:
    PHP Code:
    //Required PHP Files. 
    Typo irrelevant there.
  6. #19
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by DSmabismad
    You have probably been told most of the following, multiple times, but here it is again -

    Programming is an exact science. The computer only does exactly what the code you write tells it to do. In order to write code that accomplishes something useful, you must have a clearly defined goal for (each section of) the code. In order to write code that works, you must learn, through research, enough about the statements you are using, in each language - php, sql, javascript, css, html, so that you can use them correctly. Knowing what the statements do, what each one is contributing to the goal, is how you troubleshoot problems when the code doesn't work. You determine at what point the code is doing what you expect and at what point it is not.

    To get php and your code to help you, you need to ALWAYS -

    1) Have php set up so that it reports (error_reporting should be set to E_ALL) and displays (display_errors should be set to ON) or logs (log_errors should be set to ON) all errors and doesn't hide any output if you have any header() redirects in the code (output buffering should be set to OFF.)

    2) Have error handling (either using exceptions or program logic) for all statements that can fail.

    3) Validate all input data before using it and set up unique and helpful error messages for each different validation test that fails.

    If you store the error messages from the error handling and validation in an array, the array serves as a error flag. If the array is empty, there are no errors. If the array is not empty, there are errors.

    Your current goal is to upload a file, check for upload errors, validate the uploaded file information, then finally use the uploaded file information.

    I recommend that you forget about any extra things and start with the just the html and php you need to do this. Once you have learned how to upload a file, you can add other things to this.

    To do this, you need form processing code, which should come before the start of your html document, and you need a valid html document (your current document isn't even valid, with markup coming after the </html> tag) that contains a form that is capable of uploading a file (requires a post method form, with an enctype attribute, and a type='file' form field.) You also need to write and test each functional part of the code before going onto the next.

    Processing a post method form has an error mode, due to the total submitted post data exceeding the post_max_size setting, where the $_FILES (and $_POST) array will be empty. After you detect that a post method form has been submitted, you must detect this error condition. There are other things that can cause the $_FILES array to be empty - invalid form, uploads not enabled on the server. For a minimal application, you can just test if the $_FILES array is empty. If the array is empty, set up an appropriate error message.

    After testing for the above condition, continue with the upload error checking.

    After you have determined that the file was successfully uploaded, you can validate the things about the uploaded file that you care about.

    After you have validated the uploaded file information, you can use the submitted data.

    So, to get you started, here is an outline of the logic you need -

    PHP Code:
    <?php

    $errors 
    = []; // define an array to hold errors

    //Check whether the form was submitted or not.
    if($_SERVER["REQUEST_METHOD"] == "POST")
    {
        
    // detect the post_max_size error mode here...
        
    if(empty($_FILES))
        {
            
    $errors['file'] = "Total posted data exceeds server maximum size setting."// you can add more specific infomraiton to this message by using the #_SERVER['CONTENT_LENGTH'] and post_max_size values
        
    }
        
        
    // check for uplaod errors, in the $_FILES[...]['error'] element here...
        
    if(empty($errors))
        {
            
        }
        
        
    // if no upload errors, validate the uploded file information here...
        
    if(empty($errors))
        {
            
        }
        
        
    // if no erros, use the submitted data here...
        
    if(empty($errors))
        {
            
        }
    }

    // the html docuement starts here...
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Member Identity Video Verification Page</title>
    <meta charset="utf-8">
    </head>
    <body>
    <?php
    // display any errors
    if(!empty($errors))
    {
        echo 
    implode('<br>',$errors);
    }
    ?>
    <form enctype="multipart/form-data" method="POST">
    <label>Video File:
    <input type="file" name="id_verification_video_file"></label>
    <button type="submit">Submit!</button>
    </form>
    </body>
    </html>
    Ok. I can use your guidance list as a reference when building my form. But, I got to start learning from a valid source as it is obvious I learnt (whatever little I learnt) from outdated tutorial.
    This tutorial looks abit like your sample. Do you suggest I learn from it ? Or, is that outdated too ?
    https://www.tutorialspoint.com/php/p..._uploading.htm

    Or, do you suggest this one instead ?
    https://www.startutorial.com/article...utorial_part_1
    https://www.startutorial.com/article...utorial_part_2

    This is the tutorial I used to build-up my buggy code:
    https://www.tutorialrepublic.com/php...ile-upload.php
    I guess you would not suggest I continue learning from there. Right ?
    Last edited by UniqueIdeaMan; June 19th, 2018 at 08:21 PM.
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    Normally I'd be quite amazed that someone could use the right variable in one area and a completely different variable in another area, but I know you copy and paste **** and have no clue what's going on. So I'm not.
    Compare my code and the tutorial code here:
    https://www.tutorialrepublic.com/php...ile-upload.php

    Now tell me, I simply copied & pasted from there. Mate.
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by gw1500se
    Clearly the variable has NOT been set or you would not be getting that error. Once again, what debugging have you done on your own (Hint: print_r)?
    Array ( [id_verification_video_file] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
  12. #22
  13. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,472
    Rep Power
    2105
    Originally Posted by UniqueIdeaMan
    Array ( [id_verification_video_file] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
    That shows exactly what is wrong! See, that's why you debug - so you can actually see those errors instead of guessing. Now that you know what the problem is, look up how to fix it.
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,472
    Rep Power
    653
    Originally Posted by Catacaustic
    Now that you know what the problem is, look up how to fix it.

    LOL, good luck with that suggestion. I smell a cross post coming.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    143
    Rep Power
    66
    Originally Posted by UniqueIdeaMan
    Ok. I can use your guidance list as a reference when building my form. But, I got to start learning from a valid source as it is obvious I learnt (whatever little I learnt) from outdated tutorial.
    This tutorial looks abit like your sample. Do you suggest I learn from it ? Or, is that outdated too ?
    https://www.tutorialspoint.com/php/p..._uploading.htm

    Or, do you suggest this one instead ?
    https://www.startutorial.com/article...utorial_part_1
    https://www.startutorial.com/article...utorial_part_2

    This is the tutorial I used to build-up my buggy code:
    https://www.tutorialrepublic.com/php...ile-upload.php
    I guess you would not suggest I continue learning from there. Right ?
    STOP. All of these tutorials are missing details that would either get the code to work for all possible input conditions or tell the user/developer why it isn't working, i.e. create a good User eXperience (UX.) None of them handle the post max size error. One of them doesn't detect if there are upload errors before referencing the uploaded file information. Of the two that do detect if there are upload errors, only one sets up user error messages for each error.

    Rather than to continue trying to find and follow along with information on the web, do what I suggested and define what you want to happen, then write and test code that does what you want.

    The next step in the process is to - check for upload errors, in the $_FILES[...]['error'] element.

    You need to decide what the code should do for each of the possible upload error values (you can find a list of them in the php.net upload handling documentation.) One of the tutorials you listed does have a switch/case statement to do something for each possible error, however outputting the php.net error definition is not a good user experience and for the case of no error/a successful upload, I recommend that you separate the logic that validates and then uses the submitted form data from the upload error checking logic.

    For the errors that the user has control over (upload size, a partial/aborted upload, and not selecting a file), you need to set up error messages for these that tell the user what happened and let the user attempt to upload again. For the errors that the user doesn't have control over, you need to set up a generic error message, that the file could not be processed due to a server error, and then log the actual reason, so that you can find and fix the server-side problems.

    If the user is required to upload a file, the UPLOAD_ERR_NO_FILE (4) error code should result in a user error message telling the user that they must select and upload a file. If the user is NOT required to upload a file, you would ignore this error code (it would not add any element to the $errors array and the rest of the upload processing code would be skipped.)

    So, while you can start by making use of the switch/case logic from one of the tutorials for this step in the processing, make it your 'own' by making the user error messages meaningful for what an untrained user should see.

    Once you complete and test this step in the processing, go onto the next step - validate the uploaded file information.
  18. #25
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by DSmabismad
    STOP. All of these tutorials are missing details that would either get the code to work for all possible input conditions or tell the user/developer why it isn't working, i.e. create a good User eXperience (UX.) None of them handle the post max size error. One of them doesn't detect if there are upload errors before referencing the uploaded file information. Of the two that do detect if there are upload errors, only one sets up user error messages for each error.

    Rather than to continue trying to find and follow along with information on the web, do what I suggested and define what you want to happen, then write and test code that does what you want.

    The next step in the process is to - check for upload errors, in the $_FILES[...]['error'] element.

    You need to decide what the code should do for each of the possible upload error values (you can find a list of them in the php.net upload handling documentation.) One of the tutorials you listed does have a switch/case statement to do something for each possible error, however outputting the php.net error definition is not a good user experience and for the case of no error/a successful upload, I recommend that you separate the logic that validates and then uses the submitted form data from the upload error checking logic.

    For the errors that the user has control over (upload size, a partial/aborted upload, and not selecting a file), you need to set up error messages for these that tell the user what happened and let the user attempt to upload again. For the errors that the user doesn't have control over, you need to set up a generic error message, that the file could not be processed due to a server error, and then log the actual reason, so that you can find and fix the server-side problems.

    If the user is required to upload a file, the UPLOAD_ERR_NO_FILE (4) error code should result in a user error message telling the user that they must select and upload a file. If the user is NOT required to upload a file, you would ignore this error code (it would not add any element to the $errors array and the rest of the upload processing code would be skipped.)

    So, while you can start by making use of the switch/case logic from one of the tutorials for this step in the processing, make it your 'own' by making the user error messages meaningful for what an untrained user should see.

    Once you complete and test this step in the processing, go onto the next step - validate the uploaded file information.
    Thanks.
    Ok. You did the first bit twice now by giving guidance how it should be coded. Now, how-about doing the second or last bit by showing a code sample. I can then try memorizing your code. Ofcourse, I won't copy as is. Will modify a little. You can see how well I learn from it and then customize it to my needs. And then you can give me a score.
    How about that ?
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    143
    Rep Power
    66
    If you are unwilling to make the attempt, just give up. Programming is a do it yourself activity.
  22. #27
  23. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,961
    Rep Power
    4575
    Help Vampires don't do the work themselves.
    -- Cigars, whiskey and wild, wild women. --
  24. #28
  25. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Location
    Worldwide
    Posts
    48
    Rep Power
    45
    Originally Posted by UniqueIdeaMan
    You can see how well I learn...
    Bwah ha haaa, LMFAO! You have been at this at least a year and a half and STILL cant do the basics and are STILL trying to bait people to GIVE you code. I am surprised people are still responding to your posts. Don't bother replying because I am not the least bit interested.
  26. #29
  27. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,961
    Rep Power
    4575
    I'm glad he's still here asking dumb questions. At least it's something going on in here and is entertaining.
    -- Cigars, whiskey and wild, wild women. --
  28. #30
  29. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,561
    Rep Power
    4550
    Originally Posted by Sepodati
    I'm glad he's still here asking dumb questions. At least it's something going on in here and is entertaining.
    Ditto. There were quite a lot of regular posters that got banned a couple years ago, dunno if that was related to the decline in activity here.
    ======
    Doug G
    ======
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo