Help needed for Amazon S3 SDK

Live Link

Why is the var_dump not generating anything on the upload button? →

<?php
declare(strict_types=1);
error_reporting(E_ALL);
ini_set('display_errors', 'true');
?>

<?php 
if (isset($_FILES['file'])) {
  $file = $_FILES['file'];

  $name = $file['name'];
  $tmp_name = $file['tmp_name'];

  $ext = explode('.',$name);
  var_dump($ext);
}
?>

<?php require '../includes/header.php'; ?>
<h1>Upload </h1>
<form method="post" enctype="" class="form-inline">
  <div class="form-group">
    <input type="file" name="file">    
  </div>
  <div class="form-group">
  <input type="submit" value="Upload" class="btn btn-primary">    
  </div>
</form>



<?php require '../includes/footer.php'; ?>

If you do a var_dump() on $_FILES do you get anything output?

1 Like

Why is the form enctype set to an empty string?

1 Like

and why does it not have an action?

1 Like

By Mistake.

According to MDN an action is not essential:

When specified with no attributes, as below, the <form> data is sent to the same page that the form is present on:

<form>
2 Likes

Problem was a non problem or a Pseduo problem sorry for that. some padding issue was there so output was invisible.
Did this →
image

Var_dump is visible now.

@John_Betong has replied to this.

Hi There, did you wanted to say that function is not applicable there?

When you submit to the same page action is not required.

2 Likes

I have one more question, which is slightly different from the title.

I have this arrangement →

But when I am trying to include upload.php it generates a warning.
Warning : require(…app/init.php): failed to open stream: No such file or directory in /home1/…/amazons3/public/upload.php on line 6

This is line 6 →

<?php require '../app/init.php'; ?>

I still feel I am not making any mistake, but still, the error is there.

Woulda thought you of all people benanamen would be arguing that you should still put it there even if it’s not required.

Odd, missing a require should be an E_FATAL, not an E_WARN… (technically it should be E_COMPILE_ERROR which should be raised at E_FATAL level)

Regardless. “..” means “Go up one level”. Start at upload.php, and follow the path you have given. Do you get to init.php? (Hint: No) What does the path need to be to get to the directory you’re trying to reach, given your starting point?

EDIT: okay Marc, you’ve really gotta stop posting at 4 in the morning before you learn to read.
If the file is being included by another file, the relative paths become relative to the file that’s including upload.php.

1 Like

So could this be the reason →

If yes, what will the remedial solution?

What is the file name that is put into the browser to load the page?

This one →

if you’re directly calling example.com/upload.php, and the file exists where your screenshot shows on the server, then the line as written should work.

1 Like

Are you sure you’ve uploaded init.php ? Either it doesnt exist, or your webserver only serves files from the /public folder, because going to http://app.trafficopedia.com/amazons3/app/init.php gives me a 404.

1 Like

image

vendor folder was not uploaded that may be causing issue. I am uploading it now.

Aside: I see why it generated an E_WARN though, it failed to find where indicated, but was still digging through its possible Path folders. It E_FATAL’d once it ran out of possible locations to look in.