php - Image auto resize if image size is too large after upload -
I searched around the Internet, and working on the following code:
this permission At this time, for users to upload an image, there are some restrictions in it, such that the file size is too large, it will not be uploaded. I want to remove it and instead scale it down to proportionally (to maintain quality), unless it is less than 80000KB, if image is uploaded then it is too big or almost 350 width x 125 height My second problem is that when the file is uploaded, it indicates where it is stored, for example, "upload / picture.jpg" I like it, instead the full url Provided Was, so that when someone clicks on it, then take it directly to the image file page.
Even now I have the page where the user uploads the image
& Lt; Input type = "submit" name = "submit" value = "submit" & gt; & Lt; / Form & gt;
The upload function is found on a different page itself
& lt ;? Php if ($ _FILES ["file"] ["error"]> 0) {echo "error:" $ _FILES ["file"] ["error"] "& Lt; br & gt;"; } Else {Resonance "Upload:" $ _FILES ["File"] ["Name"] "& lt; br & gt;"; Echo "type:" $ _FILES ["file"] ["type"] "& lt; br & gt;"; "Size:" echo ($ _FILES ["file"] ["size"] / 1024). "KB
"; Echo "stored in:" $ _FILES ["file"] ["tmp_name"]; }? & Gt; & Lt ;? Php $ permissible = array ("GIF", "JPG", "JPG", "PNG"); $ Temp = Explosion (".", $ _FILES ["file"] ["name"]); $ Extension = end ($ temp); If (($ $ _FILES ["file"] ["type"] == "image / gif") ($ _FILES ["file"] ["type"] == "image / JPEG") || ($ $ _FILES ["file"] ["type"] == "image / JPG") ($ _FILES ["file"] ["type"] == "image / PJPAG") ($ _FILES ["file" ] ["Type"] == "image / x-png") ($ _FILES ["file"] ["type"] == "image / PNG")) & amp; amp; amp; amp; Amp; $$ _FILES ["File"] ["Size"] <20000) & amp; Amp; And_re ($ extension, $ permission allowed) {if ($ _FILES ["file"] ["error"]> gt; {} "echo" error: "$ _FILES [" file "] [" error "] "& Lt; br & gt;"; } Else {Resonance "Upload:" $ _FILES ["File"] ["Name"] "& lt; br & gt;"; Echo "type:" $ _FILES ["file"] ["type"] "& lt; br & gt;"; "Size:" echo ($ _FILES ["file"] ["size"] / 1024). "KB
"; Echo "stored in:" $ _FILES ["file"] ["tmp_name"]; }} Else {dumb "invalid file"; }? & Gt; & Lt ;? Php $ permissible = array ("GIF", "JPG", "JPG", "PNG"); $ Temp = Explosion (".", $ _FILES ["file"] ["name"]); $ Extension = end ($ temp); If (($ $ _FILES ["file"] ["type"] == "image / gif") ($ _FILES ["file"] ["type"] == "image / JPEG") || ($ $ _FILES ["file"] ["type"] == "image / JPG") ($ _FILES ["file"] ["type"] == "image / PJPAG") ($ _FILES ["file" ] ["Type"] == "image / x-png") ($ _FILES ["file"] ["type"] == "image / PNG")) & amp; amp; amp; amp; Amp; $$ _FILES ["file"] ["size"] & amp; amp; amp; amp; & amp; in_array ($ extension, $ permission has been granted) {{$ _FILES ["file"] ["error"]> gt:: ". $ _FILES [" file "] [" error "]." "
";} Else {resonance} "Upload:" $ _FILES ["file"] ["name"] "& lt; br & gt;" echo "type:" $ _FILES ["file"] ["type"] "& br < Gt; "size:" echo ($ _FILES ["file"] ["size"] / 1024). "KB
" resonant "temp file:" $ _FILES ["file"] ["Tmp_name"] "& quot; file_exists (" upload / ". $ _FILES [" file "] [" name "])) {echo $ _FILES [" file "] [" name "]" Already exists. ";} Else {move_uploaded_file ($ _ FILES [" file "] [" tmp_name "]," upload / ". $ _FILES ["file"] ["name"]); Echo "stored in:" "upload" $ _FILES ["file"] ["name"]; }}} And {echo "invalid file"; }? & Gt;
Any help or suggestion would be greatly appreciated
Comments
Post a Comment