473,625 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

resize an image and upload it to server

13 New Member
resize an image and upload it to server
Jul 9 '07 #1
7 1681
mwasif
802 Recognized Expert Contributor
Upload the image to server and resize it.
Jul 9 '07 #2
pbmods
5,821 Recognized Expert Expert
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
rinkudhimar
13 New Member
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 New Member
this forums awsome!! all i needed was a function to get image dimensions...go t a lot more than that....good work people
Jul 12 '07 #5
rinkudhimar
13 New Member
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 Recognized Expert Top Contributor
OK. Now we can see some code (difficult to read without tags!!) what is the problem?
Jul 12 '07 #7
ak1dnar
1,584 Recognized Expert Top Contributor
(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
9804
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 client-side and not have to upload the large raw image to the server. Thanks in advance for your help. Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in...
14
2778
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 they look bad. So what is the best way to resize an image. I'm not too concerned about size, but I guess I would like to compress it on the upload. Any thoughts?
2
2141
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). For example, if the image is max. 400 pixel in height or max. 400 pixel width or max. 100 Kb. The image is not uploaded. How can I do this? Additionally, I also want to resize the images to a valid size when
15
5328
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
1
2156
by: joe | last post by:
Any articles relating with Uploading images files to server and resize the image by asp.net 2.0
6
4517
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 are very huge (3MB) and I do resize them anyway since I only allow 500px wide pictures. Instead of letting people upload the 3MB file then resize it on the server,
5
2246
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 hold of the image first so do you store them to a temporary location first etc.??? This will be a web app. Any advice/discussion would be very helpful.
12
3352
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 tutorials correctly. My problem is when i upload an image it does not fit any case in the open_image function switch statement. when i echo $file i get 0808...tmp on my localhost server and 0808.... on my webhosting server. There is no .jpg even if...
7
17049
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 = "photo/thumbs/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images
3
2464
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 the binary data for the file. I can sucessfully take the files out of the databse again and display them in a data grid. I would like to resize the submitted file to a fixed size (say 180 x 120) before I upload it to the database and do this without...
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8352
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.