I have made a student management system which is working perfectly fine on my local machine(using WAMP Server) but when i host it, it doesn't work properly. I am trying to store student details in a database. Every detail except image path is being stored. Using wamp server its working, but it does not work when i host it. I also tried using whole path including domain name, folder but it doesn't help. Following is a code snippet:- if ($_POST['submit']) { include 'db_connect.php'; $file=$_FILES['image']['tmp_name']; $image= addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name= addslashes($_FILES['image']['name']); move_uploaded_file($_FILES["image"]["tmp_name"],"photos/" . $_FILES["image"]["name"]); $location="photos/" . $_FILES["image"]["name"]; $matric = $_POST['matric']; $name = $_POST['name']; $sem=$_POST['sem']; $sex=$_POST['sex']; $tel=$_POST['tel']; $address=$_POST['address']; $data = $_POST['picture']; $course = $_POST['course']; $data = addslashes(fread(fopen($picture, "r"), filesize($picture))); $pjpeg="image/pjpeg"; $jpeg="image/jpeg"; $gif="image/gif"; $png="image/png"; $bmp="image/bmp"; if ($picture_type == $pjpeg OR $picture_type == $jpg OR $picture_type == $gif OR $picture_type == $png OR $picture_type == $bmp) { $sql="INSERT INTO info (matric, name, course, sem, sex, tel, address ,location) VALUES ('$matric', '$name', '$course', '$sem', '$sex', '$tel', '$address', '$location')"; $result=mysql_query($sql); PHP:
One more thing, i just saw my free hosting php config. There is a line:- File Uploads file_uploads Whether to allow HTTP file uploads. Off Is it because of this only ?
learn how to debug. place this code after the first { print_r($_FILES);exit; PHP: then review the output and look up what the output means. especially the error bit
that means that that no file has actually been sent. make sure that your form tag has this parameter in it enctype="multipart/form-data" ie <form action="upload_file.php" method="post" enctype="multipart/form-data"> Code (markup):
This is my form code's first line:- <form method="post" action="student_form.php" enctype="multipart/form-data" name='s' onsubmit='return validated()';> HTML:
@stephan file_uploads has been set to off in php config. Its a free hosting. I cannot change it. Is that the reason why its not working ?
@Stephan I have signed up in another website providing free hosting. I have uploaded the script. But in the new free hosting service, even the "insert into" statement is not working. Does all the free hosting services have limited php support. ? Any other free hosting service which provides full php support ? Thanks for help
yeah pretty much all of the free hosts have limitations. what are you trying to do? maybe it is better to try it on your own computer ( install xampp or similar )
Yes, i have WAMP installed on my machine. Its awesome. But this is my college project, i am supposed to host it somewhere and submit the link. Web hosting is a must requirement and i dont want to remove "file upload" feature.
try these guys www[DOT]000webhost[DOT]com. I don't trust them though so don't upload any sensitive data.