0

I am trying to send two files/images in a form but request is stalled. It is always pending. In my local VM Box it works but on server the problem that i mentioned is occurred. I checked out php version, jQuery version and they are all same with my local. What is the problem?

EDIT 1: Here is form:

<form method="POST" id="package-create-form" action="/admin/packages/pack">
   <div class="form-group">
      <label for="image" class="bold">IMAGE</label>
      <input type="file" class="form-control" id="image" name="image">
    </div>
    <div class="form-group">
       <label for="map-image" class="bold">MAP IMAGE</label>
       <input type="file" class="form-control" id="map-image" name="map_image">
    </div>
    <div class="text-right">
       <input type="hidden" name="_token" value="{{csrf_token()}}">
       <button type="button" class="btn btn-danger" id="cancel-button"
           data-href="/admin/packages/pack"><i class="fa fa-arrow-left"></i>Back</button>
       <button type="submit" id="store-btn2"
           class="btn btn-primary">Forward<i class="fa fa-arrow-right"></i>
       </button>
    </div>
</form>
Dovydas Šopa
  • 2,242
  • 8
  • 24
  • 31
Jacin
  • 56
  • 1
  • 6

1 Answers1

0

First of all you have to write correct enctype for form.
This is enctype="multipart/form-data" for images. It's required
And second one, if you'd like to upload more than one image, you have to use tag multiple in your input type="file".
To sum up:
<form method="POST" id="package-create-form" action="/admin/packages/pack" enctype="multipart/form-data"> and
<input type="file" class="form-control" id="map-image" name="map_image" multiple>
More about enctype

Community
  • 1
  • 1
Grynets
  • 2,151
  • 15
  • 34
  • Thank you for your answer. First, I added enctype="multipart/form-data" on my previous tries. It changes nothing. Second, multiple tag is necessary when you want to upload multiple files in an input. On the contrary, i want to upload two files on two different inputs. – Jacin Feb 14 '17 at 14:56
  • I got it, try to get your files with $_FILES on your backend (php script) side, `print_r($_FILES)`. And you have to see your images (their data(names, folder path and size). – Grynets Feb 14 '17 at 15:53
  • The form could not to be sent to back-end. I change the action with http://google.com but result is same. So the request is stucked between ajax request and back-end and never reach to url. It is very very mysterious situation for me. – Jacin Feb 15 '17 at 12:34
  • Does your backend script exists on http(s)://your_url/admin/packages/pack ? Are you sure that you wrote path correctly? Maybe try to create test file, like test.php on /admin/packages/test.php and than send your form there? – Grynets Feb 15 '17 at 13:37
  • Yes it does. I will try test again. – Jacin Feb 16 '17 at 13:31