ziedinjsh Posted October 8, 2011 Report Share Posted October 8, 2011 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.. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 8, 2011 Report Share Posted October 8, 2011 Varbūt sāc atkļūdot? Izmanto maģisko funkciju print_r($_FILES) Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 9, 2011 Author Report Share Posted October 9, 2011 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 ) ) Quote Link to comment Share on other sites More sharing options...
briedis Posted October 9, 2011 Report Share Posted October 9, 2011 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. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 10, 2011 Author Report Share Posted October 10, 2011 (edited) ieliekot error_log(print_r($_FILES, true)); un veicot procesu parādās tukša lapa! Edited October 10, 2011 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 10, 2011 Report Share Posted October 10, 2011 Atver savu 'log' failu un paskaties, kas tur jauns. Un jā, sāc domāt! :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.