Jump to content
php.lv forumi

uploads


ziedinjsh

Recommended Posts

kapēc neaugšupielādē bildes!?

 

jquery:


$(function(){
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
action: 'process/uploadphoto_process.php',
name: 'photo',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                   // extension is not allowed 
status.text('Only JPG, PNG or GIF files are allowed');
return false;
}
status.text('Uploading...');
},
onComplete: function(file, response){
//On completion clear the status
status.text('');
//Add uploaded file to list
if(response==="success"){
$('<li></li>').appendTo('#files').html('<img src="photos/'+file+'" alt="" /><br />'+file).addClass('success');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});

});

 

html:


<div id='upload'><span>Upload File<span></div><span id='status'></span>
<ul id='files' ></ul>

 

php:


$folder = "../photos/";
$aid = mysql_real_escape_string($_POST['aid']);

$image = mysql_real_escape_string($_FILES['photo']['name']);
$tmp = mysql_real_escape_string($_FILES['photo']['tmp_name']);

$photo = basename($_FILES['photo']['name']);
$uploading = $folder.basename($_FILES['photo']['name']);

if(move_uploaded_file($_FILES['photo']['tmp_name'], $uploading)){
$sql = mysql_query("insert into photos (aid, photo) values ('$aid', '$photo')") or die(mysql_error());

photo70("../photos/","../photos/small/",70);
photo200("../photos/","../photos/medium/",200);
photo500("../photos/","../photos/",500);

echo "ir";
}else{
echo "nav";

} 

 

uzvēlotioes bildi man viņš viņu neaugšupielādē bet tikai parādā bildes nosaukumu sarkanā rāmī un viss..

Link to comment
Share on other sites

izveidojot parastu upload formu

 


<form method='post' action='process/uploadphoto_process.php' enctype='multipart/form-data'>
<input type='file' name='photo'>
<input type='submit' name='addphoto' value='pievienot'>
</form>

 


$folder = "../photos/";
$aid = mysql_real_escape_string($_POST['aid']);

$image = mysql_real_escape_string($_FILES['photo']['name']);
$tmp = mysql_real_escape_string($_FILES['photo']['tmp_name']);

$photo = basename($_FILES['photo']['name']);
$uploading = $folder.basename($_FILES['photo']['name']);

print_r($_FILES)

 

Array ( [photo] => Array ( [name] => DSC07743.JPG [type] => image/jpeg [tmp_name] => D:\wamp\tmp\php1507.tmp [error] => 0 => 2081642 ) )

Link to comment
Share on other sites

Nu redz, šeit viss ir ok. Tagad vajag secināt - problēma ir JS pusē, vai PHP pusē. Kā Tu zini, ka vispār tas ajax uploads kaut ko padod tam php?

 

Pievieno php failam

error_log(print_r($_FILES, true));

atver error logu un skaties, kādus datus saņem php.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...