title: Image uploads successfully, but browser throws 404 error on android
body: <p>I have a very weird error here, I have successfully uploaded an image in my web server, i mean it shows there, but when i try to open it, it says "The requested URL xxxx was not found on this server". Here is the ss of it:</p>
  
  <p><img src="https://i.stack.imgur.com/QEnmC.png" alt="Image not found"></p>
  
  <p>and here the file is clearly on the server: </p>
  
  <p><img src="https://i.stack.imgur.com/kO7fr.png" alt="web server screenshot"></p>
  
  <p>And here is my Android code in case you need it:</p>
  
  <pre><code>public void uploadimage(){
      Intent intent = new Intent();
      intent.setType("image/*");
      intent.setAction(Intent.ACTION_GET_CONTENT);
      startActivityForResult(Intent.createChooser(intent, "Select Image From Gallery"), 1);
  
  
  }
  @Override
  protected void onActivityResult(int RC, int RQC, Intent I) {
  
      super.onActivityResult(RC, RQC, I);
  
      if (RC == 1 &amp;&amp; RQC == RESULT_OK &amp;&amp; I != null &amp;&amp; I.getData() != null) {
  
          Uri uri = I.getData();
  
          try {
  
              bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
              profile_pic.setImageBitmap(bitmap);
              ImageUploadToServerFunction();
  
          } catch (IOException e) {
  
              e.printStackTrace();
          }
      }
  }
  public void ImageUploadToServerFunction(){
      created=false;
  
      ByteArrayOutputStream byteArrayOutputStreamObject ;
  
      byteArrayOutputStreamObject = new ByteArrayOutputStream();
  
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStreamObject);
  
      byte[] byteArrayVar = byteArrayOutputStreamObject.toByteArray();
      long lengthbmp = byteArrayVar.length;
          final String ConvertImage = Base64.encodeToString(byteArrayVar, Base64.DEFAULT);
  
          class AsyncTaskUploadClass extends AsyncTask&lt;Void, Void, String&gt; {
  
              @Override
              protected void onPreExecute() {
  
                  super.onPreExecute();
  
                  progressDialog = ProgressDialog.show(AccountInfoActivity.this, "Image is Uploading", "Please Wait", false, false);
              }
  
              @Override
              protected void onPostExecute(String string1) {
  
                  super.onPostExecute(string1);
  
                  // Dismiss the progress dialog after done uploading.
                  progressDialog.dismiss();
  
                  // Printing uploading success message coming from server on android app.
                  Toast.makeText(AccountInfoActivity.this, string1, Toast.LENGTH_LONG).show();
                  profile_pic.setImageBitmap(bitmap);
                  // Setting image as transparent after done uploading.
  
  
              }
  
              @Override
              protected String doInBackground(Void... params) {
                  ImageProcessClass imageProcessClass = new ImageProcessClass();
  
                  HashMap&lt;String, String&gt; HashMapParams = new HashMap&lt;String, String&gt;();
  
                  HashMapParams.put(ImageName, accessSharedPreferences.getFullName(AccountInfoActivity.this)+"-1234567890");
  
                  HashMapParams.put(ImagePath, ConvertImage);
  
                  String FinalData = imageProcessClass.ImageHttpRequest(ServerUploadPath, HashMapParams);
  
                  return FinalData;
              }
          }
          AsyncTaskUploadClass AsyncTaskUploadClassOBJ = new AsyncTaskUploadClass();
  
          AsyncTaskUploadClassOBJ.execute();
  
  }
  public class ImageProcessClass {
  
      public String ImageHttpRequest(String requestURL, HashMap&lt;String, String&gt; PData) {
  
          StringBuilder stringBuilder = new StringBuilder();
  
          try {
  
              URL url;
              HttpURLConnection httpURLConnectionObject;
              OutputStream OutPutStream;
              BufferedWriter bufferedWriterObject;
              BufferedReader bufferedReaderObject;
              int RC;
  
              url = new URL(requestURL);
  
              httpURLConnectionObject = (HttpURLConnection) url.openConnection();
  
              httpURLConnectionObject.setReadTimeout(19000);
  
              httpURLConnectionObject.setConnectTimeout(19000);
  
              httpURLConnectionObject.setRequestMethod("POST");
  
              httpURLConnectionObject.setDoInput(true);
  
              httpURLConnectionObject.setDoOutput(true);
  
              OutPutStream = httpURLConnectionObject.getOutputStream();
  
              bufferedWriterObject = new BufferedWriter(
  
                      new OutputStreamWriter(OutPutStream, "UTF-8"));
  
              bufferedWriterObject.write(bufferedWriterDataFN(PData));
  
              bufferedWriterObject.flush();
  
              bufferedWriterObject.close();
  
              OutPutStream.close();
  
              RC = httpURLConnectionObject.getResponseCode();
  
              if (RC == HttpsURLConnection.HTTP_OK) {
  
                  bufferedReaderObject = new BufferedReader(new InputStreamReader(httpURLConnectionObject.getInputStream()));
  
                  stringBuilder = new StringBuilder();
  
                  String RC2;
  
                  while ((RC2 = bufferedReaderObject.readLine()) != null) {
  
                      stringBuilder.append(RC2);
                  }
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }
          return stringBuilder.toString();
      }
  
      private String bufferedWriterDataFN(HashMap&lt;String, String&gt; HashMapParams) throws UnsupportedEncodingException {
  
          StringBuilder stringBuilderObject;
  
          stringBuilderObject = new StringBuilder();
  
          for (Map.Entry&lt;String, String&gt; KEY : HashMapParams.entrySet()) {
  
              if (check)
  
                  check = false;
              else
                  stringBuilderObject.append("&amp;");
  
              stringBuilderObject.append(Uri.encode(KEY.getKey(), "UTF-8"));
  
              stringBuilderObject.append("=");
  
              stringBuilderObject.append(Uri.encode(KEY.getValue(), "UTF-8"));
          }
  
          return stringBuilderObject.toString();
      }
  
  }
  </code></pre>
  
  <p>php code for uploading:</p>
  
  <pre><code>&lt;?php
  
  
  // Create connection
   $conn = mysqli_connect("x.x.x.x", "xxxxx", "xxxx", "xxxxx");
  
   if($_SERVER['REQUEST_METHOD'] == 'POST')
   {
   $DefaultId = 0;
  
   $ImageData = $_POST['image_path'];
  
   $ImageName = $_POST['image_name'];
  
   $GetOldIdSQL ="SELECT id FROM UploadImageToServer ORDER BY id ASC";
  
   $Query = mysqli_query($conn,$GetOldIdSQL);
  
   while($row = mysqli_fetch_array($Query)){
  
   $DefaultId = $row['id'];
   }
  
   $ImagePath = "images/$ImageName.jpg";
  
   $ServerURL = "http://raymartsison.x10host.com/uploads/$ImagePath";
  
   $InsertSQL = "insert into UploadImageToServer (image_path,image_name) values ('$ServerURL','$ImageName')";
  
   if(mysqli_query($conn, $InsertSQL)){
  
   file_put_contents($ImagePath,base64_decode($ImageData));
  
   echo "Your Image Has Been Uploaded.";
   }
  
   mysqli_close($conn);
   }else{
   echo "Not Uploaded";
   }
  
  ?&gt;
  </code></pre>
  
  <p>I consider it weird because the first file on the screen shot("Aw aw-1234567890.jpg")works perfectly, but others do not. Another reason is when i try to rename or change the extension of those weird files, the error goes away and i am able to open them.
  Any help will be very much appreciated.
  EDIT:
  url of not working image:
  <a href="http://raymartsison.x10host.com/uploads/images/se%20se-1234567890.jpg" rel="nofollow noreferrer">http://raymartsison.x10host.com/uploads/images/se%20se-1234567890.jpg</a></p>
  
  <p>url working(renamed):
  <a href="http://raymartsison.x10host.com/uploads/images/se%20se-123456789.jpg" rel="nofollow noreferrer">http://raymartsison.x10host.com/uploads/images/se%20se-123456789.jpg</a></p>