473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

resize an image and upload it to server

resize an image and upload it to server
Jul 9 '07 #1
7 1665
mwasif
802 Expert 512MB
Upload the image to server and resize it.
Jul 9 '07 #2
pbmods
5,821 Expert 4TB
Heya, rinkudhimar.

Sure.

For $100.

Seriously now. You're going to have to give us more info than that.

Have you at least TRIED to implement it?
Jul 9 '07 #3
yes
the code is

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. $userfile_name="image/terrest_gif.gif";
  4. $add="e:/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name.
  5. if(copy($userfile_name, $add)){
  6. echo "Successfully uploaded the image";
  7. chmod("$add",777);
  8. }else
  9. {
  10. echo "Failed to upload file Contact Site admin to fix the problem";
  11. exit;}
  12. $n_width=100; // Fix the width of the thumb nail images
  13. $n_height=100; // Fix the height of the thumb nail imaage
  14. $tsrc="c:/$userfile_name"; // Path where thumb nail image will be stored
  15.  
  16. if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/terrest_gif.gif"))
  17. {
  18. echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
  19. exit;
  20. }
  21.  
  22. if (@$userfile_type=="image/terrest_gif.gif"){
  23. $im=ImageCreateFromGIF($add);
  24. echo "$im";
  25. $width=ImageSx($im);  
  26. echo "$width";            // Original picture width is stored
  27. $height=ImageSy($im);      
  28. echo $height;      // Original picture height is stored
  29. $newimage=imagecreatetruecolor($n_width,$n_height);
  30. imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
  31.  
  32. if (function_exists("imagegif")) {
  33. Header("Content-type: image/gif");
  34. ImageGIF($newimage,$tsrc);
  35. }
  36. elseif (function_exists("imagejpeg")) {
  37. Header("Content-type: image/jpeg");
  38. ImageJPEG($newimage,$tsrc);
  39. }
  40.  
  41. chmod("$tsrc",777);
  42. if($userfile_type=="image/pjpeg"){
  43. $im=ImageCreateFromJPEG($add);
  44. $width=ImageSx($im); // Original picture width is stored
  45. $height=ImageSy($im); // Original picture height is stored
  46. $newimage=imagecreatetruecolor($n_width,$n_height);
  47. imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
  48. ImageJpeg($newimage,$tsrc);
  49. chmod("$tsrc",777);
  50. }
  51. }
  52. ?>
  53.  
Heya, rinkudhimar.

Sure.

For $100.

Seriously now. You're going to have to give us more info than that.

Have you at least TRIED to implement it?
Format for the code tag is [code=language] [ / CODE]. not <code>. Full list of Code Tag Supported Languages
Jul 11 '07 #4
developing
110 100+
this forums awsome!! all i needed was a function to get image dimensions...got a lot more than that....good work people
Jul 12 '07 #5
I am also expecting answers to my question and not such funny comments daily. I have sent the full code just because you get a detailed idea. Anyways I think that you cannot help at all.
Jul 12 '07 #6
code green
1,726 Expert 1GB
OK. Now we can see some code (difficult to read without tags!!) what is the problem?
Jul 12 '07 #7
ak1dnar
1,584 Expert 1GB
(difficult to read without tags!!)
Now It's ready to go.
Jul 12 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Don | last post by:
Does anyone know where I can find a client-side function I can reference from within an HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it on the...
14
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why...
2
by: IkBenHet | last post by:
Hello, I use an ASP.NET script on my website to upload images (complete script is listed at the end of this message). Now, I want to limit the size (in width and height, but also in bytes)....
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
1
by: joe | last post by:
Any articles relating with Uploading images files to server and resize the image by asp.net 2.0
6
by: Bob Bedford | last post by:
Hi all, I've a classic upload form where people may select images on their computer to send on my website. Since this is done by people not very confortable with computers, some sent pictures...
5
by: bungle | last post by:
Hi Would anyone be able to offer advice on how they would upload images to SQL Server 2005 so that if they are too big the system will automatically resize them first? Obviously you need to get...
12
by: Shawn Northrop | last post by:
Ive been searching for an image resize tutorial for a while now and found this code which worked nicely. I was unable to find the full source code but i think i pieced together the code from the...
7
by: mishrarajesh44 | last post by:
hii all Truly telling i hav got this code from net & i am finding error while running the code below.. code:- <?php $idir = "photo/"; // Path To Images Directory $tdir =...
3
by: pozze | last post by:
Hi, I've just made the change from ASP to .net. I have a file (code below) that saves a user submitted file to a MS SQL 2005 database. It collects the file name, file size, file type, and lastly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.