3

I am using this code on my site.

It is working perfect, but I need the max height of the picture to be 600px and if larger auto resizes during upload, right now it validates how big in size only (in bites).

Not sure if should be done at the javascript level or in the upload.php based where I was reading, anyhow no luck on my end.

Any assistance is really appreciated it.

Narendra Jadhav
  • 10,052
  • 15
  • 33
  • 44
Speego
  • 71
  • 7
  • what about resize your picture before save to disk?? – HoangHieu Apr 25 '18 at 04:07
  • https://stackoverflow.com/questions/18805497/php-resize-image-on-upload – HoangHieu Apr 25 '18 at 04:07
  • **WARNING**: When using `mysqli` you should be using [parameterized queries](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and [`bind_param`](http://php.net/manual/en/mysqli-stmt.bind-param.php) to add user data to your query. **DO NOT** use string interpolation or concatenation to accomplish this because you have created a severe [SQL injection bug](http://bobby-tables.com/). **NEVER** put `$_POST`, `$_GET` or **any** user data directly into a query, it can be very harmful if someone seeks to exploit your mistake. – tadman Apr 25 '18 at 04:12
  • Try and stay *away* from low quality "tutorials" like this. Consider using a [development framework](http://codegeekz.com/best-php-frameworks-for-developers/) to solve problems like this. These give you patterns to follow for organizing your code into proper model, view and controller contexts and avoids ending up with confused concerns, with HTML, PHP, SQL, and JavaScript all jumbled together. Frameworks come in many forms from really lean like [Fat-Free Framework](https://fatfreeframework.com/) to full-featured like [Laravel](http://laravel.com/). – tadman Apr 25 '18 at 04:12
  • 1
    If that tutorial can't be bothered to properly parameterize their queries in 2018 that tutorial is worthless and will get you into trouble *fast*. – tadman Apr 25 '18 at 04:13

1 Answers1

1
<td><img src="files/'.$row["image_name"].'" class="img-thumbnail" width="100" height="100" /></td>

width and height from this snippet from the code constrain the img to the value but you can add a css class and class definition max-height: 600px

Daouda
  • 101
  • 8