franknu Posted December 18, 2006 Share Posted December 18, 2006 Can anyone tell me why is not working. the problem is that file is being uploaded on a diffrent folder and it is not saving the path int the databasei want the file to be upload it in this folder("/home/townsfin/public_html/business_images/ ") and instead it is being send to this folder("/home/townsfin/public_html/")on top of that it is not saving the path in the database for the file here is my code [code=php:0]<?php $uploaddir = realpath ("/home/townsfin/public_html/business_images/ "); $uploadfile = $uploaddir . basename($_FILES['Picture1']['name']); if(!empty($_FILES['Picture1'])) { var_dump($uploaddir); var_dump($_FILES['Picture1']['size']); var_dump($_FILES['Picture1']['error']); var_dump($_FILE); var_dump($_FILES['Picture1']['type']); var_dump($_FILES['Picture1']['name']); } if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $uploaddir .$_FILES['Picture1']['name'])) { echo("File Uploaded"); echo("$uploaddir"); echo("$uploadfile"); } else { echo ("file no uploaded!"); print_r($_FILES); echo realpath('./'); } ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/ Share on other sites More sharing options...
HuggieBear Posted December 18, 2006 Share Posted December 18, 2006 Why are you using realpath() on a path that's already 'real'?The following should work fine:[code]<?php$uploaddir = '/home/townsfin/public_html/business_images/'; // No need for realpath() here$uploadfile = $_FILES['Picture1']['name']; // No need for basename() hereif(!empty($_FILES['Picture1'])){ var_dump($uploaddir); var_dump($_FILES['Picture1']['size']); var_dump($_FILES['Picture1']['error']); var_dump($_FILE); var_dump($_FILES['Picture1']['type']); var_dump($_FILES['Picture1']['name']); } $fullpath = $uploaddir . $uploadfile;if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){ echo("File Uploaded"); echo("$uploaddir"); echo("$uploadfile"); } else { echo ("file no uploaded!"); print_r($_FILES); echo realpath('./'); }?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/#findComment-143669 Share on other sites More sharing options...
franknu Posted December 18, 2006 Author Share Posted December 18, 2006 everything is ok the only problem; is that it is no saving the path in the databasethank u Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/#findComment-143690 Share on other sites More sharing options...
HuggieBear Posted December 18, 2006 Share Posted December 18, 2006 OK, well you didn't post that part of the code.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/#findComment-143695 Share on other sites More sharing options...
franknu Posted December 18, 2006 Author Share Posted December 18, 2006 ok this is where i want to post the file path in my database [code=php:0]$uploaddir = '/home/townsfin/public_html/business_images/'; // No need for realpath() here$uploadfile = $_FILES['Picture1']['name']; // No need for basename() hereif(!empty($_FILES['Picture1'])){ var_dump($uploaddir); var_dump($_FILES['Picture1']['size']); var_dump($_FILES['Picture1']['error']); var_dump($_FILE); var_dump($_FILES['Picture1']['type']); var_dump($_FILES['Picture1']['name']); } $fullpath = $uploaddir . $uploadfile;if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){ echo("File Uploaded"); // FILE PATH INSERT COLUM Picture1 $sql="INSERT INTO `business_info` where (`Picture1`=`Picture1`)} else { echo ("file no uploaded!"); print_r($_FILES); echo realpath('./'); }[/code]any idea what i should do there my error messageParse error: syntax error, unexpected T_STRING in /home/townsfin/public_html/html_forms/insert_data.php on line 142 Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/#findComment-143728 Share on other sites More sharing options...
HuggieBear Posted December 18, 2006 Share Posted December 18, 2006 OK, something like this would do it...[code]<?php$uploaddir = '/home/townsfin/public_html/business_images/'; // No need for realpath() here$uploadfile = $_FILES['Picture1']['name']; // No need for basename() hereif(!empty($_FILES['Picture1'])){ var_dump($uploaddir); var_dump($_FILES['Picture1']['size']); var_dump($_FILES['Picture1']['error']); var_dump($_FILE); var_dump($_FILES['Picture1']['type']); var_dump($_FILES['Picture1']['name']); } $fullpath = $uploaddir . $uploadfile;if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){ echo("File Uploaded"); $sql = "INSERT INTO business_info (picture1) VALUES ('$fullpath')"; $result = mysql_query($sql); if (!$result){ echo "Error inserting data: " . mysql_error(); }} else { echo ("file no uploaded!"); print_r($_FILES); echo realpath('./'); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31114-recording-path-in-the-database/#findComment-143857 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.