<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[image upload , resize e in database]]></title><description><![CDATA[<h2>Ciao a tutti.....<br />
ho creato un database e un form tutto trovato in rete e messo in dreamweaver che in teoria dovrebbe inserirmi le immagini in 2 directory separate ,una per le imm.originali l'altra per le resize , nel db dovrebbe inserirmi il luogo , il titolo, il nome della immagine normale , il nome dell'immagine resize ......<br />
Mi aiutate a capire da questo codice come e' possibile fare questo....<br />
db<br />
-- phpMyAdmin SQL Dump<br />
-- version 2.10.3<br />
-- <a href="http://phpmyadmin.net" rel="nofollow ugc">phpmyadmin.net</a></h2>
<h2>-- Host: localhost<br />
-- Generato il: 17 Giu, 2008 at 08:57 PM<br />
-- Versione MySQL: 5.0.51<br />
-- Versione PHP: 5.2.6<br />
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";</h2>
<h2>-- Database: <code>immagini</code></h2>
<hr />
<h2>--<br />
-- Struttura della tabella <code>immagini</code></h2>
<h2>CREATE TABLE <code>immagini</code> (<br />
<code>id</code> int(11) unsigned NOT NULL auto_increment,<br />
<code>luogo</code> varchar(255) NOT NULL,<br />
<code>titolo</code> varchar(255) NOT NULL,<br />
<code>image_orig</code> varchar(255) NOT NULL,<br />
<code>image_small</code> varchar(255) NOT NULL,<br />
PRIMARY KEY (<code>id</code>)<br />
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;</h2>
<h2>-- Dump dei dati per la tabella <code>immagini</code></h2>
<hr />
<p dir="auto">codice php</p>
<p dir="auto">&lt;?php require_once('Connections/immagini.php'); ?&gt;<br />
&lt;?php<br />
if (!function_exists("GetSQLValueString")) {<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")<br />
{<br />
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br />
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br />
switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}<br />
}<br />
$editFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />
}<br />
if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "something")) {<br />
$insertSQL = sprintf("INSERT INTO immagini (luogo, titolo, image_orig, image_small) VALUES (%s, %s, %s, %s)",<br />
GetSQLValueString($_POST['luogo'], "text"),<br />
GetSQLValueString($_POST['titolo'], "text"),<br />
GetSQLValueString($_POST['new_image'], "text"),<br />
GetSQLValueString($_POST['new_image'], "text"));<br />
mysql_select_db($database_immagini, $immagini);<br />
$Result1 = mysql_query($insertSQL, $immagini) or die(mysql_error());<br />
}<br />
?&gt;&lt;form name="something" action="&lt;?php echo $editFormAction; ?&gt;" method="POST" enctype="multipart/form-data" id="something" class="uniForm"&gt;<br />
&lt;table width="424" border="0"&gt;<br />
&lt;tr&gt;<br />
&lt;td height="31" colspan="3"&gt;&lt;input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /&gt;<br />
&lt;button name="submit" type="submit" class="submitButton"&gt;Upload/Resize Image&lt;/button&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td width="62"&gt; &lt;/td&gt;<br />
&lt;td width="150"&gt; &lt;/td&gt;<br />
&lt;td width="198"&gt; &lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td colspan="2"&gt;&lt;label&gt;<br />
&lt;input name="luogo" type="text" id="luogo" size="30" /&gt;<br />
&lt;/label&gt;&lt;/td&gt;<br />
&lt;td&gt;Luogo&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td colspan="2"&gt;&lt;label&gt;<br />
&lt;input name="titolo" type="text" id="titolo" size="30" /&gt;<br />
&lt;/label&gt;&lt;/td&gt;<br />
&lt;td&gt;Titolo&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;td&gt; &lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;p&gt; &lt;/p&gt;<br />
&lt;p&gt; &lt;/p&gt;<br />
&lt;p&gt; &lt;/p&gt;<br />
&lt;input type="hidden" name="MM_insert" value="something" /&gt;<br />
&lt;/form&gt;<br />
&lt;?php<br />
if(isset($_POST['submit'])){<br />
if (isset ($_FILES['new_image'])){<br />
$imagename = $_FILES['new_image']['name'];<br />
$source = $_FILES['new_image']['tmp_name'];<br />
$target = "images/".$imagename;<br />
move_uploaded_file($source, $target);</p>
<p dir="auto">$imagepath = $imagename;<br />
$save = "images_resize/" . $imagepath; //This is the new file you saving<br />
$file = "images/" . $imagepath; //This is the original file<br />
list($width, $height) = getimagesize($file) ;</p>
<p dir="auto">$modwidth = 150;</p>
<p dir="auto">$diff = $width / $modwidth;</p>
<p dir="auto">$modheight = $height / $diff;<br />
$tn = imagecreatetruecolor($modwidth, $modheight) ;<br />
$image = imagecreatefromjpeg($file) ;<br />
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;</p>
<p dir="auto">imagejpeg($tn, $save, 100) ;<br />
$save = "images/sml_" . $imagepath; //This is the new file you saving<br />
$file = "images/" . $imagepath; //This is the original file<br />
list($width, $height) = getimagesize($file) ;</p>
<p dir="auto">$modwidth = 80;</p>
<p dir="auto">$diff = $width / $modwidth;</p>
<p dir="auto">$modheight = $height / $diff;<br />
$tn = imagecreatetruecolor($modwidth, $modheight) ;<br />
$image = imagecreatefromjpeg($file) ;<br />
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;</p>
<p dir="auto">imagejpeg($tn, $save, 100) ;<br />
echo "Large image: &lt;img src='images/".$imagepath."'&gt;&lt;br&gt;";<br />
echo "Thumbnail: &lt;img src='images/sml_".$imagepath."'&gt;";<br />
}<br />
}<br />
?&gt;</p>
<p dir="auto">GRAZIE MILLE<img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/6551d194-c64c-4e45-9dcf-2a85dc41b3fb-sun.gif?v=3abbd2034aa" class="not-responsive emoji emoji-customizations emoji--sun" style="height:1.4em;width:auto;vertical-align:middle" title=":sun:" alt="" /><br />
vi allego 2 file per l'upload se interessano.......</p>
]]></description><link>https://dev.connect.gt/topic/74309/image-upload-resize-e-in-database</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Dec 2026 15:56:22 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/74309.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Jun 2008 21:00:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to image upload , resize e in database on Wed, 18 Jun 2008 16:59:49 GMT]]></title><description><![CDATA[<p dir="auto">Ho risolto<br />
if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "form1")&amp;&amp; ($_FILES['new_image'])) {<br />
$insertSQL = sprintf("INSERT INTO immage (luogo, titolo, image_orig, image_small) VALUES (%s, %s, %s, %s)",<br />
GetSQLValueString($_POST['luogo'], "text"),<br />
GetSQLValueString($_POST['titolo'], "text"),<br />
GetSQLValueString($_FILES['new_image']['name'], "text"),<br />
GetSQLValueString($_FILES['new_image'] ['name'], "text"));</p>
<p dir="auto">ciaoooo<img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/3749756f-8699-4a40-9529-7b04b159b9f5-tongueout.gif?v=3abbd2034aa" class="not-responsive emoji emoji-customizations emoji--tongueout" style="height:1.4em;width:auto;vertical-align:middle" title=":tongueout:" alt="" /></p>
]]></description><link>https://dev.connect.gt/post/724490</link><guid isPermaLink="true">https://dev.connect.gt/post/724490</guid><dc:creator><![CDATA[patatrac]]></dc:creator><pubDate>Wed, 18 Jun 2008 16:59:49 GMT</pubDate></item><item><title><![CDATA[Reply to image upload , resize e in database on Tue, 17 Jun 2008 21:43:41 GMT]]></title><description><![CDATA[<p dir="auto">penso sia qui' da risolvere l'errore....</p>
<p dir="auto">$insertSQL = sprintf("INSERT INTO immagini (luogo, titolo, image_orig, image_small) VALUES (%s, %s, %s, %s)",<br />
GetSQLValueString($_POST['luogo'], "text"),<br />
GetSQLValueString($_POST['titolo'], "text"),<br />
GetSQLValueString($_POST['new_image'], "text"),<img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/1881713c-5c09-4986-bf15-fa308ef84b2e-smilegt.gif?v=3abbd2034aa" class="not-responsive emoji emoji-customizations emoji--smile5" style="height:1.4em;width:auto;vertical-align:middle" title=":smile5:" alt="" /><br />
GetSQLValueString($_POST['new_image'], "text"));</p>
]]></description><link>https://dev.connect.gt/post/724488</link><guid isPermaLink="true">https://dev.connect.gt/post/724488</guid><dc:creator><![CDATA[patatrac]]></dc:creator><pubDate>Tue, 17 Jun 2008 21:43:41 GMT</pubDate></item><item><title><![CDATA[Reply to image upload , resize e in database on Tue, 17 Jun 2008 21:40:18 GMT]]></title><description><![CDATA[<p dir="auto">OK..<br />
allora le immagini le carica nelle directory quindi tutto ok<br />
nel database non mi scrive il nome delle due immagini caricate (small e normale)<br />
grazie....</p>
]]></description><link>https://dev.connect.gt/post/724487</link><guid isPermaLink="true">https://dev.connect.gt/post/724487</guid><dc:creator><![CDATA[patatrac]]></dc:creator><pubDate>Tue, 17 Jun 2008 21:40:18 GMT</pubDate></item><item><title><![CDATA[Reply to image upload , resize e in database on Tue, 17 Jun 2008 21:34:03 GMT]]></title><description><![CDATA[<p dir="auto">Dovresti dirci se ti genera un errore, oppure non hai idea di come fare tutto. Altrimenti è impossibile aiutarti( se non ti leggi 300 righe di codice e penso che in pochi lo faranno)</p>
]]></description><link>https://dev.connect.gt/post/724437</link><guid isPermaLink="true">https://dev.connect.gt/post/724437</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Tue, 17 Jun 2008 21:34:03 GMT</pubDate></item></channel></rss>