PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
Problem mit Bilderupload!
Beitrag
<blockquote data-quote="steiner93" data-source="post: 1389102" data-attributes="member: 118896"><p>Hallo lieber user von psd-tutorials.de,</p><p>Ich habe ein problem mit meinem Bilderupload script. Immer wenn ich auf Upload klicke kommt einfach nichts und kein Bild wird hochgeladen. Hier der Link: <a href="http://creative-designs.eu/upload" target="_blank">http://creative-designs.eu/upload</a> . Und hier einmal der Code für euch : [php]<? </p><p>if($action){ </p><p></p><p> // -------------------------------- </p><p> // Diverse Variablen </p><p> // -------------------------------- </p><p> </p><p> </p><p>$html = "&lt;a href='";</p><p>$html1 = "'&gt;<br>&lt;img src='";</p><p>$html2 = "' border='0'&gt;&lt;/a&gt;";</p><p>$bbcode = "[img]";</p><p>$bbcode1 = "[/img]";</p><p>$path = "usrimages/"; // Url zum Speicherordner der großen Bilder </p><p>$thumb_path = "usrimages/k/"; // Url zum Speicherordner der Vorschaubilder </p><p>$config_width = "99999"; // Bildbreite max. bei großem Bild </p><p>$config_height = "99999"; // Bildhöhe max. bei großem Bild </p><p>$config_thumb_width = "99999"; // Bildbreite max. bei Vorschaubild </p><p>$config_thumb_height = "99999"; // Bildhöhe max. bei Vorschaubild </p><p>$resizequality = "70"; // Bildkompressionsrate 0-100 </p><p>$deindomain = "http://creative-designs.eu/upload/"; // unsere Domain </p><p></p><p>if ($HTTP_POST_FILES['userfile']['tmp_name']<> 'none') </p><p> { </p><p></p><p> // -------------------------------- </p><p> // Get File Upload Info </p><p> // -------------------------------- </p><p></p><p> $filename = $HTTP_POST_FILES['pic_file']['name']; </p><p> $filetype = $HTTP_POST_FILES['pic_file']['type']; </p><p> $filetmp = $HTTP_POST_FILES['pic_file']['tmp_name']; </p><p></p><p> // -------------------------------- </p><p> // Check file type </p><p> // -------------------------------- </p><p></p><p> switch ($filetype) </p><p> { </p><p> case 'image/jpeg': </p><p> case 'image/jpg': </p><p> case 'image/pjpeg': </p><p></p><p> $pic_filetype = '.jpg'; </p><p> break; </p><p></p><p> case 'image/png': </p><p> case 'image/x-png': </p><p></p><p> $pic_filetype = '.png'; </p><p> break; </p><p></p><p> case 'image/gif': </p><p></p><p> $pic_filetype = '.gif'; </p><p> break; </p><p> default: </p><p> die("<br><br><b>$filename hat ein falsches Dateiformat. Nur JPEG, GIF oder PNG erlaubt!</b>"); </p><p> } </p><p></p><p> // -------------------------------- </p><p> // Generate filename </p><p> // -------------------------------- </p><p></p><p> srand((double)microtime()*1000000); // for older than version 4.2.0 of PHP </p><p></p><p> do </p><p> { </p><p> $pic_filename = md5(uniqid(rand())) . $pic_filetype; </p><p> } </p><p> while( file_exists($path . $pic_filename) ); </p><p></p><p></p><p> // -------------------------------- </p><p> // Move this file to upload directory </p><p> // -------------------------------- </p><p></p><p> $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; </p><p></p><p> if ( @$ini_val('open_basedir') != '' ) </p><p> { </p><p> if ( @phpversion() < '4.0.3' ) </p><p> { </p><p> die("open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin"); </p><p> } </p><p></p><p> $move_file = 'move_uploaded_file'; </p><p> } </p><p> else </p><p> { </p><p> $move_file = 'copy'; </p><p> } </p><p></p><p> $move_file($filetmp, $path . $pic_filename); </p><p></p><p> @chmod($path . $pic_filename, 0777); </p><p></p><p></p><p> // -------------------------------- </p><p> // Well, it's an image. Check its image size </p><p> // -------------------------------- </p><p></p><p> $pic_size = getimagesize($path . $pic_filename); </p><p></p><p> $pic_width = $pic_size[0]; </p><p> $pic_height = $pic_size[1]; </p><p></p><p></p><p> // -------------------------------- </p><p> // This image is okay, we can cache its thumbnail now </p><p> // -------------------------------- </p><p></p><p> if($pic_filetype != '.gif') </p><p> { </p><p> $gd_errored = FALSE; </p><p></p><p> switch ($pic_filetype) </p><p> { </p><p> case '.jpg': </p><p> $read_function = 'imagecreatefromjpeg'; </p><p> break; </p><p> case '.png': </p><p> $read_function = 'imagecreatefrompng'; </p><p> break; </p><p> } </p><p></p><p> $src = @$read_function($path . $pic_filename); </p><p></p><p> if (!$src) </p><p> { </p><p> $gd_errored = TRUE; </p><p> $pic_thumbnail = ''; </p><p> } </p><p> else if( ($pic_width > $config_thumb_width) or ($pic_height > $config_thumb_height) ) </p><p> { </p><p> // Resize it </p><p> if ($pic_width > $pic_height) </p><p> { </p><p> $thumbnail_width = $config_thumb_width; </p><p> $thumbnail_height = $config_thumb_width * ($pic_height/$pic_width); </p><p> } </p><p> else </p><p> { </p><p> $thumbnail_height = $config_thumb_height; </p><p> $thumbnail_width = $config_thumb_height * ($pic_width/$pic_height); </p><p> } </p><p></p><p> $thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height); </p><p></p><p> $resize_function = 'imagecopyresampled'; </p><p></p><p> @$resize_function($thumbnail, $src, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); </p><p> } </p><p> else </p><p> { </p><p> $thumbnail = $src; </p><p> } </p><p></p><p> if (!$gd_errored) </p><p> { </p><p> $pic_thumbnail = $pic_filename; </p><p></p><p> // Write to disk </p><p> switch ($pic_filetype) </p><p> { </p><p> case '.jpg': </p><p> @imagejpeg($thumbnail, $thumb_path . $pic_thumbnail, $resizequality); </p><p> break; </p><p> case '.png': </p><p> @imagepng($thumbnail, $thumb_path . $pic_thumbnail); </p><p> break; </p><p> } </p><p></p><p> @chmod($thumb_path . $pic_thumbnail, 0777); </p><p></p><p> } // End IF $gd_errored </p><p></p><p> } // End Thumbnail Cache </p><p></p><p></p><p> // -------------------------------------- </p><p> // OK lets resize the original picture </p><p> // -------------------------------------- </p><p></p><p> if($pic_filetype != '.gif') </p><p> { </p><p> $gd_errored = FALSE; </p><p></p><p> switch ($pic_filetype) </p><p> { </p><p> case '.jpg': </p><p> $read_function = 'imagecreatefromjpeg'; </p><p> break; </p><p> case '.png': </p><p> $read_function = 'imagecreatefrompng'; </p><p> break; </p><p> } </p><p></p><p> $src = @$read_function($path . $pic_filename); </p><p></p><p> if (!$src) </p><p> { </p><p> $gd_errored = TRUE; </p><p> $pic_resize = ''; </p><p> } </p><p> else if( ($pic_width > $config_width) or ($pic_height > $config_height) ) </p><p> { </p><p> // Resize it </p><p> if ( (($pic_width / $pic_height) > ($config_width / $config_height)) ) </p><p> { </p><p> $resize_width = $config_width; </p><p> $resize_height = $config_width * ($pic_height/$pic_width); </p><p> } </p><p> else </p><p> { </p><p> $resize_height = $config_height; </p><p> $resize_width = $config_height * ($pic_width/$pic_height); </p><p> } </p><p></p><p> $resize = @imagecreatetruecolor($resize_width, $resize_height); </p><p></p><p> $resize_function = 'imagecopyresampled'; </p><p></p><p> @$resize_function($resize, $src, 0, 0, 0, 0, $resize_width, $resize_height, $pic_width, $pic_height); </p><p> } </p><p> else </p><p> { </p><p> $resize = $src; </p><p> } </p><p></p><p> if (!$gd_errored) </p><p> { </p><p> $pic_resize = $pic_filename; </p><p></p><p> // Write to disk </p><p> switch ($pic_filetype) </p><p> { </p><p> case '.jpg': </p><p> @imagejpeg($resize, $path . $pic_resize, $resizequality); </p><p> break; </p><p> case '.png': </p><p> @imagepng($resize, $path . $pic_resize); </p><p> break; </p><p> } </p><p></p><p> @chmod($path . $pic_resize, 0777); </p><p></p><p> } // End IF $gd_errored </p><p></p><p> } // End Picture Resize </p><p></p><p> echo "<br><br><b><u>Url des Bildes:</u></b><br><br>".$deindomain.$path.$pic_filename;</p><p> echo "<br><br><br><b><u>HTML Code zum einbinden:</u></b><br><br>".$html.$deindomain.$html1.$deindomain.$path.$pic_filename.$html2; </p><p> echo "<br><br><br><b><u>BBCode zum einbinden:</u></b><br><br>".$bbcode.$deindomain.$path.$pic_filename.$bbcode1; </p><p> echo "<br><br><br><br><br>Deine IP (<u>$ip</u>) wurde gespeichert!"; </p><p></p><p> } </p><p>} else { ?> [/php]Wäre nett wenn mir wer helfen könnte.</p><p></p><p>MfG Steiner</p></blockquote><p></p>
[QUOTE="steiner93, post: 1389102, member: 118896"] Hallo lieber user von psd-tutorials.de, Ich habe ein problem mit meinem Bilderupload script. Immer wenn ich auf Upload klicke kommt einfach nichts und kein Bild wird hochgeladen. Hier der Link: [url]http://creative-designs.eu/upload[/url] . Und hier einmal der Code für euch : [php]<? if($action){ // -------------------------------- // Diverse Variablen // -------------------------------- $html = "<a href='"; $html1 = "'><br><img src='"; $html2 = "' border='0'></a>"; $bbcode = "[img]"; $bbcode1 = "[/img]"; $path = "usrimages/"; // Url zum Speicherordner der großen Bilder $thumb_path = "usrimages/k/"; // Url zum Speicherordner der Vorschaubilder $config_width = "99999"; // Bildbreite max. bei großem Bild $config_height = "99999"; // Bildhöhe max. bei großem Bild $config_thumb_width = "99999"; // Bildbreite max. bei Vorschaubild $config_thumb_height = "99999"; // Bildhöhe max. bei Vorschaubild $resizequality = "70"; // Bildkompressionsrate 0-100 $deindomain = "http://creative-designs.eu/upload/"; // unsere Domain if ($HTTP_POST_FILES['userfile']['tmp_name']<> 'none') { // -------------------------------- // Get File Upload Info // -------------------------------- $filename = $HTTP_POST_FILES['pic_file']['name']; $filetype = $HTTP_POST_FILES['pic_file']['type']; $filetmp = $HTTP_POST_FILES['pic_file']['tmp_name']; // -------------------------------- // Check file type // -------------------------------- switch ($filetype) { case 'image/jpeg': case 'image/jpg': case 'image/pjpeg': $pic_filetype = '.jpg'; break; case 'image/png': case 'image/x-png': $pic_filetype = '.png'; break; case 'image/gif': $pic_filetype = '.gif'; break; default: die("<br><br><b>$filename hat ein falsches Dateiformat. Nur JPEG, GIF oder PNG erlaubt!</b>"); } // -------------------------------- // Generate filename // -------------------------------- srand((double)microtime()*1000000); // for older than version 4.2.0 of PHP do { $pic_filename = md5(uniqid(rand())) . $pic_filetype; } while( file_exists($path . $pic_filename) ); // -------------------------------- // Move this file to upload directory // -------------------------------- $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; if ( @$ini_val('open_basedir') != '' ) { if ( @phpversion() < '4.0.3' ) { die("open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin"); } $move_file = 'move_uploaded_file'; } else { $move_file = 'copy'; } $move_file($filetmp, $path . $pic_filename); @chmod($path . $pic_filename, 0777); // -------------------------------- // Well, it's an image. Check its image size // -------------------------------- $pic_size = getimagesize($path . $pic_filename); $pic_width = $pic_size[0]; $pic_height = $pic_size[1]; // -------------------------------- // This image is okay, we can cache its thumbnail now // -------------------------------- if($pic_filetype != '.gif') { $gd_errored = FALSE; switch ($pic_filetype) { case '.jpg': $read_function = 'imagecreatefromjpeg'; break; case '.png': $read_function = 'imagecreatefrompng'; break; } $src = @$read_function($path . $pic_filename); if (!$src) { $gd_errored = TRUE; $pic_thumbnail = ''; } else if( ($pic_width > $config_thumb_width) or ($pic_height > $config_thumb_height) ) { // Resize it if ($pic_width > $pic_height) { $thumbnail_width = $config_thumb_width; $thumbnail_height = $config_thumb_width * ($pic_height/$pic_width); } else { $thumbnail_height = $config_thumb_height; $thumbnail_width = $config_thumb_height * ($pic_width/$pic_height); } $thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height); $resize_function = 'imagecopyresampled'; @$resize_function($thumbnail, $src, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); } else { $thumbnail = $src; } if (!$gd_errored) { $pic_thumbnail = $pic_filename; // Write to disk switch ($pic_filetype) { case '.jpg': @imagejpeg($thumbnail, $thumb_path . $pic_thumbnail, $resizequality); break; case '.png': @imagepng($thumbnail, $thumb_path . $pic_thumbnail); break; } @chmod($thumb_path . $pic_thumbnail, 0777); } // End IF $gd_errored } // End Thumbnail Cache // -------------------------------------- // OK lets resize the original picture // -------------------------------------- if($pic_filetype != '.gif') { $gd_errored = FALSE; switch ($pic_filetype) { case '.jpg': $read_function = 'imagecreatefromjpeg'; break; case '.png': $read_function = 'imagecreatefrompng'; break; } $src = @$read_function($path . $pic_filename); if (!$src) { $gd_errored = TRUE; $pic_resize = ''; } else if( ($pic_width > $config_width) or ($pic_height > $config_height) ) { // Resize it if ( (($pic_width / $pic_height) > ($config_width / $config_height)) ) { $resize_width = $config_width; $resize_height = $config_width * ($pic_height/$pic_width); } else { $resize_height = $config_height; $resize_width = $config_height * ($pic_width/$pic_height); } $resize = @imagecreatetruecolor($resize_width, $resize_height); $resize_function = 'imagecopyresampled'; @$resize_function($resize, $src, 0, 0, 0, 0, $resize_width, $resize_height, $pic_width, $pic_height); } else { $resize = $src; } if (!$gd_errored) { $pic_resize = $pic_filename; // Write to disk switch ($pic_filetype) { case '.jpg': @imagejpeg($resize, $path . $pic_resize, $resizequality); break; case '.png': @imagepng($resize, $path . $pic_resize); break; } @chmod($path . $pic_resize, 0777); } // End IF $gd_errored } // End Picture Resize echo "<br><br><b><u>Url des Bildes:</u></b><br><br>".$deindomain.$path.$pic_filename; echo "<br><br><br><b><u>HTML Code zum einbinden:</u></b><br><br>".$html.$deindomain.$html1.$deindomain.$path.$pic_filename.$html2; echo "<br><br><br><b><u>BBCode zum einbinden:</u></b><br><br>".$bbcode.$deindomain.$path.$pic_filename.$bbcode1; echo "<br><br><br><br><br>Deine IP (<u>$ip</u>) wurde gespeichert!"; } } else { ?> [/php]Wäre nett wenn mir wer helfen könnte. MfG Steiner [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 7, ▼ = 3, ◇ = 2 und die Summe von ▲ und ▼ durch ◇ geteilt wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
Problem mit Bilderupload!
Oben