473,769 Members | 5,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload->resize->pathname in Mysql

1 New Member
Hello everyone,

I am new in PHP-programming but I am learning the basics of it.
I've got a script that uploads a picture together with all data from the inputform, to the server and places the pathname into the Mysql.
I desperately want to have the uploaded pictures resized in the meantime.
Does anyone know how to do this ? Or perhaps adjust the script with the functions, necessary for resizing ?

I would appreciate it VERY VERY much !
Thank you !!

script :
Expand|Select|Wrap|Line Numbers
  1. <?php require_once('../Connections/tutorial.php'); ?>
  2. <?php
  3. mysql_select_db($database_tutorial, $tutorial);
  4. $query_Recordset1 = "SELECT * FROM tut_afbeelding";
  5. $Recordset1 = mysql_query($query_Recordset1, $tutorial) or die(mysql_error());
  6. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  7. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  8.  
  9. mysql_select_db($database_tutorial, $tutorial);
  10. $query_Recordset2 = "SELECT distinct job FROM tut_afbeelding";
  11. $Recordset2 = mysql_query($query_Recordset2, $tutorial) or die(mysql_error());
  12. $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  13. $totalRows_Recordset2 = mysql_num_rows($Recordset2);
  14.  
  15.  
  16. require_once('config.php');
  17. include ("filter.php");
  18. $go = $_POST['go'];
  19. if ($go ==""): 
  20.  
  21. ?>
  22.  
  23. </head>
  24. <body>
  25. <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
  26.  
  27. <!-- Hier komt het verborgen veld 'go met de waarde 'go' -->
  28.    <input name="go" type="hidden" value="go">
  29.        <table width="450" border="0" bgcolor="#99CCFF" align="center">
  30.        <tr>
  31.          <td bgcolor="#99CCFF">Naam</td>
  32.          <td valign="baseline"><input name="naam" type="text" id="naam" value="" size="32"></td>
  33.        </tr>
  34.     <tr>
  35.       <td bgcolor="#99CCFF">Job</td>
  36.       <td valign="baseline"><select name="job" id="job">
  37.         <?php
  38. do {  
  39.  
  40.         <option value="<?php echo $row_Recordset2['job']?>"<?php if (!(strcmp($row_Recordset2['job'], $row_Recordset2['job']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset2['job']?></option>
  41.         <?php
  42. } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  43.   $rows = mysql_num_rows($Recordset2);
  44.   if($rows > 0) {
  45.       mysql_data_seek($Recordset2, 0);
  46.       $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  47.   }
  48.  
  49.         </select>
  50.       </td>
  51.     </tr>
  52.     <tr>
  53.       <td bgcolor="#99CCFF">Plaats</td>
  54.       <td valign="baseline"><input name="plaats" type="text" id="plaats" value="" size="32"></td>
  55.     </tr>
  56.     <tr>
  57.       <td bgcolor="#99CCFF">Hobby</td>
  58.       <td valign="baseline"><input name="hobby" type="text" id="hobby" value="" size="32"></td>
  59.     </tr>
  60.     <tr>
  61.       <td bgcolor="#99CCFF">Omschrijving</td>
  62.       <td><input name="omschrijving" type="text" id="omschrijving" size="50"></td>
  63.     </tr>
  64.     <tr>
  65.       <td bgcolor="#99CCFF">Afbeelding</td>
  66.       <td><input name="afbeelding" type="file" accept="image/jpeg" id="afbeelding" size="50"></td>
  67.     </tr>
  68.     <tr>
  69.       <td bgcolor="#99CCFF">&nbsp;</td>
  70.       <td><input type="submit" name="Submit" value="Verzenden">
  71.       <input type="reset" name="Reset" value="Herstellen"></td>
  72.     </tr>
  73.   </table>
  74.   <p>&nbsp;</p>
  75. </form>
  76.  
  77.  
  78. endif;
  79.  
  80.  
  81.  
  82.  
  83. if ($go =="go"):
  84.  
  85. $hello = getcwd();
  86.  
  87.  
  88. $file_dir = ($hello . "/images/");
  89.  
  90.  
  91. if (is_dir ($file_dir)) {
  92.   print "<br><br>++directorty bestaat";  
  93.   }  else {  
  94.   print "<br><br>--Directory bestaat nog niet" . $file_dir;  
  95.     $newpage = $file_dir;
  96.     echo ("<br>we gaan daarom de directory aanmaken");
  97.     mkdir ($newpage, 0777);    
  98.   }  
  99.  
  100.  
  101. echo date("m/d/y G.i:s");
  102.  
  103.  
  104. echo ("<br><br>");
  105.  
  106. foreach($_FILES as $file_name => $file_array) {
  107.  
  108.        $file_name=str_replace("'", "_", $file_array['name']);
  109.        $file_name=str_replace(" ", "_", $file_array['name']);
  110.        $file_name=stripslashes ($file_name);
  111.        $file_name=trim($file_name);       
  112.        $file_name=strtolower($file_name);    
  113.  
  114.        echo "path: " .$file_array['tmp_name'] . "<br>\n";
  115.        echo "name: " .$file_name . "<br>\n";    
  116.        echo "type: " .$file_array['type'] ."<br>\n";
  117.        echo "size: " .$file_array['size'] ."<br>\n";
  118.  
  119.  
  120.        $test = afbeeldingen($file_name);
  121.        if ($test !=""):
  122.             echo $file_name . " dit is een afbeelding<br>";
  123.             if (is_uploaded_file($file_array['tmp_name'])) {
  124.  
  125.                  move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_name") or die ("Couldn't copy");
  126.                  echo "Afbeelding staat op de server<br><br>";
  127.  
  128.                  $afbeelding = "images/" . $file_name;
  129.                  $query = "INSERT INTO tut_afbeelding (ID, naam, job, plaats, hobby, omschrijving, afbeelding) VALUES ('', '$_POST[naam]', '$_POST[job]', '$_POST[plaats]', '$_POST[hobby]', '$_POST[omschrijving]','$afbeelding')";    
  130.                     if(!mysql_db_query($dbname,$query,$db)) die(mysql_error());                      
  131.                         echo $afbeelding . " is toegevoegd aan de database met als omschrijving : <br>";                    
  132.                         echo $_POST[omschrijving] ;
  133.             }
  134.        endif;                     
  135.        if ($test ==""):    
  136.              echo $file_name . " dit is geen afbeelding en wordt daarom niet op de server geplaatst<br>\n";      
  137.        endif;
  138.   }
  139. endif;
  140.  
  141.  
  142.  
  143. mysql_free_result($Recordset1);
  144.  
  145. mysql_free_result($Recordset2);
  146. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jul 3 '07 #1
1 1812
kovik
1,044 Recognized Expert Top Contributor
Image resizing can easily be done using the GD library with the imagecoypresamp led() function.
Jul 3 '07 #2

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

Similar topics

13
64273
by: Joshua Beall | last post by:
Hi All, Is there any way for me to overcome the php.ini configuration upload_max_filesize? I cannot use ini_set() since upload_max_filesize can only be set in httpd.conf or php.ini. Are there any other options? I have an image gallery script that I wrote that will take a very large image, and resize it down to a reasonable size for the web. This makes it easy for me to grab very high resolution images from my camera, and just shoot...
1
2905
by: André Gasser | last post by:
hello newsgroup, I just discovered a weird effect in my php code. here is the flow of my code: 1. upload jepg file to server 2. create new (empty) jpeg file using imagecreatefromjpeg() function 3. use imagecopyresampled to resize src image and store in newly created image from step 2.
3
2180
by: Faree | last post by:
Hi, I am a PHP Developer.can any one help me on image upload and display of that image.what i want is uploading an image to a directory ,displaying of that image as a thumbnail.when i click on that image the image should be diplayed in another page. I wrote code for image uploading and as well as display code.but i couldn't write image resizing when click on that.:(
2
2216
by: attenborough | last post by:
Hi, am hoping that someone may be able to help me. Im designing a small website using PHP and MySQL. I would like to allow my visitors to upload a photo via a form on it. Im worried that people will be trying to upload 1mb+ images, so i am looking for a php script that will resize that image down to a managable 50kb file (or there abouts) and also give me a small thumbnail to use. Presumably then the script would also delete the original...
2
1766
by: samcode3 | last post by:
Hi, I have a page, where users can upload images, and it will be stored in MySQL as binary data(longblob). Now when i select this data from mysql to display in webpage, i want to resize the picture. Am using PHP/MySQL. Pls help me how to do this..! -sam
3
6737
by: gsoguerrilla | last post by:
Hi, I have limited knowledge in php and I am having trouble with uploading an image to a remote directory and resizing it if it's larger and renaming it to a unique id, while at the same time I would like to create a record in mysql database. I've tried to find some tutorials but I've had trouble finding any good ones. Wondering if anybody has good examples or link to a good tutorial. Thanks in advance.
5
2626
by: Objectifnet | last post by:
Is there any one who could help with a problem. I have an application that uploads images to a file server with my upload directory set thus:define('ALBUM_IMG_DIR', 'C:/Inetpub/wwwroot/sites/supportbridges/www/admin/profile/images/album/'); This is how it is on my local computer running on IIS, now I want to transfer the same application to a Linux host. What can I do to shorten the directory link so as to be able to upload images to the...
14
2010
by: Mikee Freedom | last post by:
Good Morning all, New member to the list, hoping you might be able to give me some much needed advice. Basically, I have a client who would like to offer the ability for his users to have their own independent website at his domain. It is not as clear cut as that but as a generic description it will do. I know such services exist and I'm by no means emulating there's in any
3
1261
by: Shawn Northrop | last post by:
I have created a site where users can upload images to a mysql server and then the images are displayed on another page. If possible i would like to resize the image before the data uploads. for example if the image is 1024 x 2000 and 2mb. It would resize the image to 400 x 600 and 200kb. or something of the sorts. then it would upload that data and store it in my database. As of now my script uploads, stores, and displays the image. However if...
4
2954
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload picture successfully unto the server but not so with the file name of the picture even though other parameters in my form got inserted successfuly in the database. I have read several posts on this topic including here on this site but I can't get around...
0
10211
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
9994
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
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7409
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
6673
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
5299
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
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
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.