hello guyes ..i dont know what is the problem with this code ..it was working with me before but now it just store nothing ...

when i submite the data every thing shows in the database ecept that image nothing shows there ..i attached the code here so every can view it and help me to solve it...

Thanks In advance..

<?
global $strDesc;

global $fileUpload;

global $fileUpload_name;

global $fileUpload_size;

global $fileUpload_type;

include("db_conn.php");

//this is famaily section
$mother_name=$_POST['mother_name'];
$mother_occupation=$_POST['mother_occupation'];
$father_name=$_POST['father_name'];
$father_occupation=$_POST['father_occupation'];
$address=$_POST['address'];
$home_number=$_POST['home_number'];
$mobile_number=$_POST['mobile_number'];
$best_contact_number=$_POST['best_contact_number'];
$email=$_POST['email'];
$country_of_origin=$_POST['country_of_origin'];
$cast=$_POST['cast'];
$religious_interest=$_POST['religious_interest'];
$language_spoken=$_POST['language_spoken'];

//this is applicant section

$full_name=$_POST['full_name'];
$age=$_POST['age'];
$dob=$_POST['dob'];
$hight=$_POST['hight'];
$status=$_POST['status'];
$children=$_POST['children'];
$how_many=$_POST['how_many'];
$complexion=$_POST['complexion'];
$smoker=$_POST['smoker'];
$language_spoken_app=$_POST['language_spoken_app'];
$education=$_POST['education'];
$occupation=$_POST['occupation'];
$hobbies_interests=$_POST['hobbies_interests'];
$key_attributes=$_POST['key_attributes'];
$accommodation=$_POST['accommodation'];
$criminal_record=$_POST['criminal_record'];

$uploaddir = '/app_pics/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
copy($_FILES['userfile']['tmp_name'], $uploadfile);
$link=$uploadfile;

$query=mysql_query("INSERT INTO `form_data` 
(mother_name,mother_occupation,father_name,father_occupation,address,home_number
,mobile_number,best_contact_number,email,country_of_origin,cast,religious_interest
,language_spoken,full_name,age,dob,hight,status,children,how_many,complexion,smoker
,language_spoken_app,education,occupation,hobbies_interests,key_attributes,accommodation
,criminal_record,app_pics)
".
"VALUES

('$mother_name','$mother_occupation','$father_name','$father_occupation','$address','$home_number'
,'$mobile_number','$best_contact_number','$email','$country_of_origin','$cast','$religious_interest','$language_spoken','$full_name','$age','$dob','$hight','$status','$children','$how_many','$complexion','$smoker','$language_spoken_app','$education','$occupation','$hobbies_interests','$key_attributes','$accommodation','$criminal_record','$link')");
mysql_close();

//echo("<script language='JavaScript'>");
//echo("window.location='index.html';");


?>

Dani AI

Generated

The DB showing only "/app_pics/" and no file in the folder usually means the upload never actually arrived or the script could not write it to the filesystem. posted the script, already flagged form/permission issues, and suggested inspecting the upload arrays. Below are focused, practical checks that go beyond those tips and will pinpoint the failure.

First run a quick, ordered diagnosis (stop after the first failing check): confirm the file input name in the HTML matches what the PHP expects; confirm the form is submitted with the proper multipart upload settings; inspect the contents of the PHP upload array to see if a file arrived and what error code it reports (mapping error codes tells you if PHP rejected the upload due to size, configuration, or no file selected). Check PHP settings next: make sure file uploads are enabled and that both upload_max_filesize and post_max_size are larger than your test file. Also verify upload_tmp_dir exists and has space.

If the upload error shows OK but the file still isn’t in your folder, the problem is a path or permission issue. A leading slash in your folder string makes it an absolute path (root/app_pics), which often is not where your web app lives — confirm the folder actually exists at that filesystem path. On a local Windows machine change NTFS permissions via Folder Properties -> Security (add the webserver user or test with Everyone temporarily); on Linux chown the directory to the webserver user and give write permission. Make sure the directory is writable by the process running PHP.

Finally, harden and log: write to PHP error_log on every failure, generate unique sanitized filenames to avoid overwriting, validate MIME/type and size before saving, and never inject raw file paths into SQL without parameterized queries (use mysqli or PDO). Example of a small diagnostic snippet to log upload status:

if (!empty($_FILES['userfile'])) {
  $err = $_FILES['userfile']['error'];
  switch ($err) {
    case UPLOAD_ERR_OK: $m = 'OK'; break;
    case UPLOAD_ERR_INI_SIZE: $m = 'upload_max_filesize exceeded'; break;
    case UPLOAD_ERR_FORM_SIZE: $m = 'form MAX_FILE_SIZE exceeded'; break;
    case UPLOAD_ERR_PARTIAL: $m = 'Partial upload'; break;
    case UPLOAD_ERR_NO_FILE: $m = 'No file sent'; break;
    default: $m = 'Other error ('.$err.')';
  }
  error_log('Upload status: '.$m);
}

Following those steps will narrow the cause quickly.

Recommended Answers

All 8 Replies

Is the image path actually saved to the database? Or is it blank?

Is the image actually being copied to the directory /app_pics/ ?

nothing is copied in the directory but when i view the database save the name of the directory only but nothing is copied in the directory ....

when we save any image in database thats actually means that we are saving the image name in database and uploading image some where at our server. your image name is storing in database? or ur image is properly uploading in your defined place?

will i an trying that way to store the path of the image and upload it in to specific folder on my server but the problem nothing is storing in the folder at the server ..but when i view the database it shows me that it store the folder name which is /app_pics/
thanks

ok first check ur folder permissions in which you are loading the images. it should be 775 or 777 .then you can write any file in the folder. and check your image name is in you code,why its not appearing?
r u using this form property as well?

enctype="multipart/form-data"

try the changes that i hv done

hello guyes ..i dont know what is the problem with this code ..it was working with me before but now it just store nothing ...

when i submite the data every thing shows in the database ecept that image nothing shows there ..i attached the code here so every can view it and help me to solve it...

Thanks In advance..

<?
global $strDesc;

global $fileUpload;

global $fileUpload_name;

global $fileUpload_size;

global $fileUpload_type;

include("db_conn.php");

//this is famaily section
$mother_name=$_POST['mother_name'];
$mother_occupation=$_POST['mother_occupation'];
$father_name=$_POST['father_name'];
$father_occupation=$_POST['father_occupation'];
$address=$_POST['address'];
$home_number=$_POST['home_number'];
$mobile_number=$_POST['mobile_number'];
$best_contact_number=$_POST['best_contact_number'];
$email=$_POST['email'];
$country_of_origin=$_POST['country_of_origin'];
$cast=$_POST['cast'];
$religious_interest=$_POST['religious_interest'];
$language_spoken=$_POST['language_spoken'];

//this is applicant section

$full_name=$_POST['full_name'];
$age=$_POST['age'];
$dob=$_POST['dob'];
$hight=$_POST['hight'];
$status=$_POST['status'];
$children=$_POST['children'];
$how_many=$_POST['how_many'];
$complexion=$_POST['complexion'];
$smoker=$_POST['smoker'];
$language_spoken_app=$_POST['language_spoken_app'];
$education=$_POST['education'];
$occupation=$_POST['occupation'];
$hobbies_interests=$_POST['hobbies_interests'];
$key_attributes=$_POST['key_attributes'];
$accommodation=$_POST['accommodation'];
$criminal_record=$_POST['criminal_record'];

$uploaddir = '/app_pics/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
copy($_FILES['userfile']['tmp_name'], $uploadfile);
//replace your code with this and try
$uploaddir = '/app_pics/';
			$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
			move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);

$link=$uploadfile;

$query=mysql_query("INSERT INTO `form_data` 
(mother_name,mother_occupation,father_name,father_occupation,address,home_number
,mobile_number,best_contact_number,email,country_of_origin,cast,religious_interest
,language_spoken,full_name,age,dob,hight,status,children,how_many,complexion,smoker
,language_spoken_app,education,occupation,hobbies_interests,key_attributes,accommodation
,criminal_record,app_pics)
".
"VALUES

('$mother_name','$mother_occupation','$father_name','$father_occupation','$address','$home_number'
,'$mobile_number','$best_contact_number','$email','$country_of_origin','$cast','$religious_interest','$language_spoken','$full_name','$age','$dob','$hight','$status','$children','$how_many','$complexion','$smoker','$language_spoken_app','$education','$occupation','$hobbies_interests','$key_attributes','$accommodation','$criminal_record','$link')");
mysql_close();

//echo("<script language='JavaScript'>");
//echo("window.location='index.html';");


?>

BzzBee i am realy thanks full to for ur helpe but the problem still the same and no i am not using

enctype="multipart/form-data"

i am trying this on my local PC how i can change the folder permissions?

thanks

BzzBee i am realy thanks full to for ur helpe but the problem still the same and no i am not using

i am trying this on my local PC how i can change the folder permissions?

thanks

It is good to view the actual variables in your PHP script.

var_dump($_POST, $_FILES);

Right at the top to see the contents of $_POST and $_FILES.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.