latinum_1982
Erfahrenes Mitglied
PHP:
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "tuningfieber";
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
session_start();
$session_id = $_SESSION['user_id']; //$session id
$path = "user_rating_photos/";
$valid_formats = array("jpg", "png", "gif", "bmp");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
if(strlen($name))
{
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$valid_formats))
{
if($size<(2048*2048))
{
$actual_image_name = time().'_'.$session_id.'_'.substr(str_replace(" ", "_", $txt), 5).".".$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
mysql_query("INSTER INTO rating VALUE
user_id = '$session_id',
foto='$actuel_image_name',
date=NOW()
");
//mysql_query("UPDATE users SET profile_image='$actual_image_name' WHERE uid='$session_id'");
echo "<img src='user_rating_photoss/".$actual_image_name."' class='preview'>";
}
else
echo "failed";
}
else
echo "Image file size max 1 MB";
}
else
echo "Invalid file format..";
}
else
echo "Please select image..!";
exit;
}
?>
bekomm die fehlermeldung
Warning: move_uploaded_file(user_rating_photos/1343396683_663_ip-bg.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in F:\xampp\htdocs\Tuningfieber.at\pages\upload\ajaximage.php on line 30
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'F:\xampp\tmp\php1C3.tmp' to 'user_rating_photos/1343396683_663_ip-bg.png' in F:\xampp\htdocs\Tuningfieber.at\pages\upload\ajaximage.php on line 30
failed
die zeile 30 ist dir if abfrage
PHP:
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
mysql_query("INSTER INTO rating VALUE
user_id = '$session_id',
foto='$actuel_image_name',
date=NOW()
");
//mysql_query("UPDATE users SET profile_image='$actual_image_name' WHERE uid='$session_id'");
echo "<img src='user_rating_photoss/".$actual_image_name."' class='preview'>";
}
und hier ist mein formular
HTML:
<script type="text/javascript" >
$(document).ready(function() {
$('#photoimg').live('change', function() {
$("#preview").html('');
$("#preview").html('<img src="pages/upload/loader.gif" alt="Uploading...."/>');
$("#imageform").ajaxForm({
target: '#preview'
}).submit();
});
});
</script>
<form id="imageform" method="post" enctype="multipart/form-data" action='pages/upload/ajaximage.php'>
Foto <input type="file" name="photoimg" id="photoimg" /><input type="submit" value="Senden">
</form>
<div id='preview'>
</div>