ArshSingh Posted April 3, 2014 Share Posted April 3, 2014 so i have the following code and i can't figure out what the problem is , its not uploading the image , jquery works but don't know whats going on with php i have done all the possible things , working on codes from morning , so maybe missed something in this code due to my head want some rest , a help will good : php <?php include"functions.php"; $username =$session->username; $path = "../images/"; $valid_formats = array("jpg", "png", "gif", "bmp","jpeg"); 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<(1024*1024)) // Image size max 1 MB { $actual_image_name = time().$username.".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `users` SET `profilepic`='$actual_image_name' WHERE `username`='$username'"); echo "<img src='../images/".$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; } ?> jquery $(document).ready(function() { $('#photoimg').live('change', function() { $("#profilepic-big").html(''); $("#profilepic-big").html('<img src="images/loading.gif" alt="Uploading...."/>'); $("#imageform").ajaxForm( { target: '#profilepic-big'} ).submit(); }); }); Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/ Share on other sites More sharing options...
jazzman1 Posted April 3, 2014 Share Posted April 3, 2014 Are you able to upload the image without using ajax? Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474868 Share on other sites More sharing options...
ArshSingh Posted April 3, 2014 Author Share Posted April 3, 2014 No ,,, i have tried in different ways but no success Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474874 Share on other sites More sharing options...
jazzman1 Posted April 3, 2014 Share Posted April 3, 2014 Then, you need to fix first the server side scripting before to proceed to javascript/ajax. Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474875 Share on other sites More sharing options...
ArshSingh Posted April 3, 2014 Author Share Posted April 3, 2014 Im trying but don't know whats wrong Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474879 Share on other sites More sharing options...
jazzman1 Posted April 3, 2014 Share Posted April 3, 2014 at a starting point turn on error reporting functions. Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474881 Share on other sites More sharing options...
ArshSingh Posted April 3, 2014 Author Share Posted April 3, 2014 can u please check if the mysqli_query is okay? Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474884 Share on other sites More sharing options...
jazzman1 Posted April 3, 2014 Share Posted April 3, 2014 You should tell me, I'm not a magic What I want from you is just to provide us all errors coming from your script, then we'll be able to help you effectively. Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474889 Share on other sites More sharing options...
ArshSingh Posted April 3, 2014 Author Share Posted April 3, 2014 Okay ,,, i think the error is before mysqli_query ,,, have to check it carefullg Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474892 Share on other sites More sharing options...
jazzman1 Posted April 3, 2014 Share Posted April 3, 2014 When you go to the doctor or to a hospital, is it important you understand what they say to you? Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474897 Share on other sites More sharing options...
ArshSingh Posted April 4, 2014 Author Share Posted April 4, 2014 Yup thats right Link to comment https://forums.phpfreaks.com/topic/287501-php-ajax-file-not-uploading/#findComment-1474918 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.