I have a full script of my php file.
Its a dataTable with a browse button to add new videos toe the Database and reload it in the DataTable
The problem is that the entry in the database is made, but the file never gets copied from its original location to the library/video folder.
I have tried and tried toe get it going by it seems like the part of php move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path) is never executed or something.
<?php
include 'config.php';
$sTable = "media";
$rootFolder = '../video/';
$libraryFolder = '../video/library/';
$priorityFolder = '../video/priority/';
if (!is_dir($rootFolder)) {
mkdir($rootFolder, 0777, true);
}
if (!is_dir($libraryFolder)) {
mkdir($libraryFolder, 0777, true);
}
if (!is_dir($priorityFolder)) {
mkdir($priorityFolder, 0777, true);
}
if(isset($_POST['script'])){
try {
$db = new PDO(
"mysql:host=".Config::$DB_HOST.";dbname=".Config::$DB_DATABASE.";charset=utf8",
Config::$DB_USERNAME,
Config::$DB_PASSWORD
);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print_r('CONNECTED TO DATABASE');
} catch(PDOException $e) {
print_r('ERROR CONNECTING TO DATABASE');
}
switch($_POST['script']){
case 'fetchAll':
$query = $db->prepare("SELECT * FROM $sTable");
$query->execute();
echo json_encode(array('media' => $query->fetch()));
break;
case 'insert':
$target = $_POST['file'];
$target_path = "../video/library/";
$target_path = $target_path . $target;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". $target ." has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$data = array(
':name' => $target,
':path' => $target_path);
$table = 'media';
$fields = array('name', 'path');
$parameters = array(':name', ':path');
$param = implode(',',$parameters);
$stmt = $db->prepare("INSERT INTO {$table} (name, path) VALUES (:name, :path)");
try {
$db->beginTransaction();
$stmt->execute(array("$parameters[0]" => $data[':name'], "$parameters[1]" => $data[':path']));
$db->commit();
print $db->lastInsertId();
} catch(PDOExecption $e) {
$db->rollback();
print "Error!: " . $e->getMessage() . "</br>";
}
break;
default:
print_r('default');
break;
}
}
$db = null;
?>
<script>
$(document).ready( function () {
$('#vidlib_dtable').dataTable( {
"dom": '<"top"f>rt<"bottom"lp><"clear">'
} );
} );
</script>
<script>
$("#uploadedfile").on("change", function(){
var file = this.files[0];
var fileName = file.name;
var fileSize = file.size;
var fileType = file.type;
});
$(document).ready( function () {
$("#vidUpdSubmit").click(function() {
oFiles = document.getElementById("uploadedfile").files[0];
nFiles = oFiles.name;
nSize = oFiles.size;
var myFile = $('#uploadedfile').prop("files")['name'];
var url = "./inc/MediaScripts.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
data: ({'script':'insert',
'file': nFiles}
),
cache: false,
success:function(data){
alert(data);
},error:function(errormsg){
alert('EPPIC FAIL');
}
});
return false; // avoid to execute the actual submit of the form.
});
} );
</script>
<div class="site_window_header">File manager</div>
<div>
<div class="vl_buttonPane">
<form id="vidUpdForm" action="" method="POST">
<input type="hidden" name="sctipt" value="insert" id="sctipt"/>
Choose a file to upload: <input name="uploadedfile" id="uploadedfile" type="file" /><br />
<input type="submit" id="vidUpdSubmit" value="Upload File" />
</form>
</div>
<div class="vl_rightPane">
<table id="vidlib_dtable" class="display">
<thead>
<tr>
<th>Name</th>
<th>Title</th>
<th>File path</th>
<th>Duration</th>
<th>Date uploaded</th>
<th>Uploaded by</th>
<th>Key words</th>
<th>Comments</th>
</tr>
</thead>
</table>
</div>
</div>
HERE is a link to a dropbox zip file with a manageable working copy of the program
SOLUTION: thanks to -> Alexander Ceballos
Upload Multiple Files with PHP and JQuery
So the problem isn't with $_FILES the problem is that you are not submitting the file. You are using ajax to post the file name(nfiles) and the value 'insert' with data:({'script':'insert', 'file':nfiles})which allows your script to process the the table update. However, you aren't actually posting the file since the form isn't being submitted, so $_FILES['uploadedfile] is actually undefined. You either need to actually submit the form and then you will be able to handle moving your file in the way your script is currently written. Or you need to add the file to your ajax post which will require you to create a form data object var formData = new FormData();. Check this page out for more on uploading files with ajax or have a look at this example. Hope this helps.
Related
I'm able to get the file uploaded and in to the directory I want so that part seems to work but I'm not sure why I'm getting a parse error in the js console in chrome. Because of this error my bottom javascript won't execute and I need it to do so.
Here's the ajax:
var files;
// Add events
$('input[type=file]').on('change', prepareUpload);
// Grab the files and set them to our variable
function prepareUpload(event)
{
files = event.target.files;
}
$('form').on('submit', uploadFiles);
// Catch the form submit and upload the files
function uploadFiles(event)
{
event.stopPropagation(); // Stop stuff happening
event.preventDefault(); // Totally stop stuff happening
// START A LOADING SPINNER HERE
// Create a formdata object and add the files
var data = new FormData();
$.each(files, function(key, value)
{
data.append(key, value);
});
$.ajax({
url: 'submit.php?files',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function(data, textStatus, jqXHR)
{
alert(data);
script = $(data).text();
$.globalEval(script);
if(typeof data.error === 'undefined')
{
// Success so call function to process the form
submitForm(event, data);
}
else
{
// Handle errors here
console.log('ERRORS: ' + data.error);
}
},
error: function(jqXHR, textStatus, errorThrown)
{
// Handle errors here
console.log('ERRORS: ' + textStatus);
// STOP LOADING SPINNER
}
});
}
Here's the html:
<?php
echo '<span class="new_profile_save_upload_image_span"><img src="'.$url_root.'/images/615721406-612x612.jpg"/ class="new_profile_save_upload_image_img"></span>';
?>
<form action="" method="post" enctype="multipart/form-data" name="new_profile_save_upload_image_input_form" id="new_profile_save_upload_image_input_form">
<input type="file" id="new_profile_save_upload_image_input" name="new_profile_save_upload_image_input" multiple="" accept="image/x-png,image/gif,image/jpeg"/>
<input type="submit" value="Upload Image" name="submit">
</form>
And here is the php:
<?php
// get mysqli db connection string
$mysqli = new mysqli("localhost", "psych_admin", "asd123", "psych");
if($mysqli->connect_error){
exit('Error db');
}
// Get theme settings and theme colours and assign the theme colour to the
theme name
$stmt = $mysqli->prepare("SELECT name FROM user_profiles WHERE rowid=(SELECT
MAX(rowid) FROM user_profiles);");
$stmt->execute();
$result = $stmt->get_result();
while($row_1 = $result->fetch_assoc())
{
$arr_1[] = $row_1;
}
foreach($arr_1 as $arrs_1)
{
$username = $arrs_1['name'];
}
$data = array();
if(isset($_GET['files']))
{
$error = false;
$files = array();
// Make dir for file uploads to be held
if (!file_exists(''.dirname(__FILE__) . '/content/profiles/'.$username.'/avatar'))
{
mkdir(''.dirname(__FILE__) . '/content/profiles/'.$username.'/avatar', 0777, true);
}
$uploaddir = './content/profiles/'.$username.'/avatar/';
foreach($_FILES as $file)
{
if(move_uploaded_file($file['tmp_name'], $uploaddir .basename($file['name'])))
{
$files[] = $uploaddir .$file['name'];
}
else
{
$error = true;
}
}
$data = ($error) ? array('error' => 'There was an error uploading your files') : array('files' => $files);
}
else
{
$data = array('success' => 'Form was submitted', 'formData' => $_POST);
}
echo json_encode($data);
?>
<script>
var scope1 = '<?php echo $url_root;?>';
var scope2 = '<?php echo $username;?>';
var scope3 = '<?php echo $file['name'];?>';
var new_profile_save_upload_image_span_data = '<img src="' + scope1 + '/content/profiles/' + scope2 + '/avatar/' + scope3 + '" class="new_profile_save_upload_image_img">';
$('.new_profile_save_upload_image_span').empty();
$('.new_profile_save_upload_image_span').append(new_profile_save_upload_image_span_data);
</script>
alert(data) doesn't seem to be popping up, so there's something wrong previous to that execution.
I tried this code with simply 'submit.php' but it doesn't seem to work without the 'files' addition to it.
Also do I have the filename correct? Should the file's filename be $file['name'] in php? I'm trying to get the file name as a string and place it in when the default image is (as an image to be displayed), using an img html tag and inserting it via jquery, as you can see at the bottom under .
The ajax should execute this script at the bottom but it doesn't due to the error.
Also is there a nicer way of writing the bottom jquery scripts that I have written?
Error I'm getting:
ERRORS: Syntax Error: Unexpected Token < in JSON at position 103
Thanks in advance.
If you want to return JSON and HTML at the same time, you could put the HTML into an element of the $data array.
<?php
// get mysqli db connection string
$mysqli = new mysqli("localhost", "psych_admin", "asd123", "psych");
if($mysqli->connect_error){
exit('Error db');
}
// Get theme settings and theme colours and assign the theme colour to the
theme name
$stmt = $mysqli->prepare("SELECT name FROM user_profiles WHERE rowid=(SELECT
MAX(rowid) FROM user_profiles);");
$stmt->execute();
$result = $stmt->get_result();
while($row_1 = $result->fetch_assoc())
{
$arr_1[] = $row_1;
}
foreach($arr_1 as $arrs_1)
{
$username = $arrs_1['name'];
}
$data = array();
if(isset($_GET['files']))
{
$error = false;
$files = array();
// Make dir for file uploads to be held
if (!file_exists(''.dirname(__FILE__) . '/content/profiles/'.$username.'/avatar'))
{
mkdir(''.dirname(__FILE__) . '/content/profiles/'.$username.'/avatar', 0777, true);
}
$uploaddir = './content/profiles/'.$username.'/avatar/';
foreach($_FILES as $file)
{
if(move_uploaded_file($file['tmp_name'], $uploaddir .basename($file['name'])))
{
$files[] = $uploaddir .$file['name'];
}
else
{
$error = true;
}
}
$data = ($error) ? array('error' => 'There was an error uploading your files') : array('files' => $files);
}
else
{
$data = array('success' => 'Form was submitted', 'formData' => $_POST);
$data['html'] = <<<EOS
<script>
var scope1 = '$url_root';
var scope2 = '$username';
var scope3 = '{$file['name']}';
var new_profile_save_upload_image_span_data = '<img src="' + scope1 + '/content/profiles/' + scope2 + '/avatar/' + scope3 + '" class="new_profile_save_upload_image_img">';
\$('.new_profile_save_upload_image_span').empty();
\$('.new_profile_save_upload_image_span').append(new_profile_save_upload_image_span_data);
</script>
EOS;
}
echo json_encode($data);
?>
Then in the JavaScript you do:
script = $(data.html).text();
It's better to use try-catch block in your PHP code, and send status with the response set to true or false. Also, send the $url_root and $username variables within the JSON object.
See this beginner's guide on Image Uploading with PHP and AJAX to learn everything about creating AJAX handler, validating, saving and sending a response back to the client side.
I'm using the blueimp File Upload Plugin with Yii to try and upload a file to my server (currently localhost). I gave the folder full read / write permissions (the location is C:\xampp\htdocs\yii), but I still get an error when I try to do the move_uploaded file command.
Here is the main form and input file area:
<form id='upload' method='post' action='?r=site/move' enctype='multipart/form-data' style="padding:0;">
<span class="btn fileinput-button" style="padding:0">
<i class="glyphicon glyphicon-picture">
<input id="fileupload" type="file" accept="image/*" name="attachment" onchange="attachAttachment()">
</i>
</span>
</form>
Here is blueimp's fileupload (in function()):
$("#fileupload").fileupload
({
dataType: 'json',
done: function (e, data)
{
console.log("YAY");
},
fail: function(e, data)
{
console.log("FAIL");
}
});
Here is the actionMove, where I move the file from the temp directory to the folder:
public function actionMove()
{
if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == 0)
{
if (move_uploaded_file($_FILES['attachment'], Yii::getPathOfAlias('webroot')."/images/uploads")){
$response = '{"status":"success"}';
}
else {
$response = '{"status":"error"}';
}
echo $response;
exit();
}
}
I have been at this for hours now, any help is appreciated :(
$_FILES['attachment'] references all data about the download. move_uploaded_file uses filenames to work. Here is what you should try:
$uploadPath = Yii::getPathOfAlias('webroot')."/images/uploads";
$uploadFilename = basename($_FILES['attachment']['name']);
$tempFilename = $_FILES['attachment']['tmp_name'];
$ok = move_uploaded_file($tempFilename, $uploadPath.'/'.$uploadFilename);
if ($ok) {
$response = '{"status":"success"}';
} else {
$response = '{"status":"error"}';
}
More on this on the documentation pages:
http://php.net/manual/fr/features.file-upload.post-method.php
and
http://php.net/manual/fr/function.move-uploaded-file.php
Hope it helps.
I have fair knowledge of JS, PHP and Ajax but this simple problem has driven me nuts.
I am trying to upload an image silently, without using a form. I am not using a form because that will lead to nested forms in my HTML, which I read, can cause additional issues.
I have been able to use oFReader, to preview the images.
To upload the image, I am attempting an AJAX call as given below:
HTML
<div id="loginButton2">
<div id="personalimg" >
<img src="photos/seller_photos/<?php echo $profile_pic; ?>" width="70" hight="70" />
</div>
</div>
<div id="loginBox2" style="display:none">
<div id="loginForm2" class="floatLeft" >
<fieldset>
<input id="file" type="file" name="profile_img" value="photos/seller_photos/<?php echo $profile_pic;?>"/>
<input id="file_submit" type="hidden" name="submit4" value="1" >
</fieldset>
</div>
</div>
JS
$('#file').change(function(){
var oFReader = new FileReader();
oFReader.readAsDataURL(this.files[0]);
var fd = new FormData();
var file = $("#file").prop("files")[0];
fd.append('profile_img', file);
fd.append('submit4', 1);
fd.append('filename', 1);
oFReader.onload = function (oFREvent) {
$.ajax({
url: "upload.php",
dataType: 'image',
cache: false,
contentType: false,
processData: false,
type: "POST",
data: fd,
success: function(data){
console.log(data);
},
error: function(){
console.log("image upload failed");
}
});
$('#loginForm2').toggle();
$('#personalimg').html('<img src="'+oFREvent.target.result+'" width="70" height="70">');
};
});
PHP
if(isset($_POST['submit4'])) {
$check_sql = "select profile_pic from profile where user_id=$user_id";
$check_rs = mysql_query($check_sql);
$check_num = mysql_num_rows($check_rs);
if($check_num==0) {
$sql = "insert into profile(user_id) values($user_id)";
$rs = mysql_query($sql);
}
$fName = $_FILES["profile_img"]["name"] ;
$data = explode(".", $fName);
$fileName = $user_id.'.'.$data[1];
if($fName!='')$user->update('profile_pic',$fileName);
$fileTmpLoc= $_FILES["profile_img"]["tmp_name"];
//image store path
$pathAndName = "photos/seller_photos/".$fileName;
$moveResult = move_uploaded_file($fileTmpLoc, $pathAndName);
if(move_uploaded_file) {
$response['status'] = '1';
header('Location: edit_profile_new.php');
} else {
$response['status'] = '0';
}
return $response;
}
But somehow, I have not been able to get this to work. I am using chrome. I get 302 Found status code and "image upload failed" in console.
Can someone please help me out?
ps: I know, mysql is deprecated and will migrate to pdo. This code is inherited and hence has old standards.
This question already has answers here:
How can I upload files asynchronously with jQuery?
(34 answers)
Closed 8 years ago.
I want to do is make a image uploader system and send the image to upload folder and save the link to the database.
My problem is I got this to errors in my images.php can anyone help me with this please.
html:
<form method="post" enctype="multipart/form-data">
<img id="picture" data-src="#" /> <br />
<input type='file' name="image" id="imgInp" accept="image/*" /><br />
<input type="submit" name="submit" id="submit" value="submit" />
</form>
script:
<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function (e) {
e.preventDefault();
var data = {};
data.image = $('#imgInp').val();
$.ajax({
type: "POST",
url: "images.php",
data: data,
cache: false,
success: function (response) {
}
});
return false;
});
});
</script>
images.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
$dbc = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$image = addslashes(file_get_contents(#$_FILES['image']['tmp_name']));
$image_name = addslashes(#$_FILES['image']['name']);
$image_size = getimagesize(#$_FILES['image']['tmp_name']);
move_uploaded_file(#$_FILES["image"]["tmp_name"], "upload/" . #$_FILES["image"]["name"]);
$location = "upload/" . #$_FILES["image"]["name"];
$q = "INSERT INTO students( image ) VALUES( :image)";
$query = $dbc->prepare($q);
$query->bindParam(':image', $location);
$results = $query->execute();
?>
script for image upload:
<script type="text/javascript">
$(document).ready(function() {
var currentSrc = $('#picture').attr('src');
if(currentSrc==null || currentSrc==""){
$('#picture').attr('src','http://i38.photobucket.com/albums/e149/eloginko/profile_male_large_zpseedb2954.jpg');
$("#picture").on('click', function() {
$("#imgInp").trigger('click')}
)}
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#picture').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});
});
</script>
The simplest thing to get rid of the error messages is to actually place a conditional that checks if $_FILES has anything in it. But past that, unclear on the root cause of $FILES being empty. In my experience Ajax file uploading with a PHP receiver on the other side just doesn’t work consistently at best. Anyway, here is my version of your code with a conditional in place:
if (!empty($_FILES)) {
$image = addslashes(file_get_contents(#$_FILES['image']['tmp_name']));
$image_name = addslashes(#$_FILES['image']['name']);
$image_size = getimagesize(#$_FILES['image']['tmp_name']);
move_uploaded_file(#$_FILES["image"]["tmp_name"], "upload/" . #$_FILES["image"]["name"]);
$location = "upload/" . #$_FILES["image"]["name"];
$q = "INSERT INTO students( image ) VALUES( :image)";
$query = $dbc->prepare($q);
$query->bindParam(':image', $location);
$results = $query->execute();
}
Try this approach, it might look like too many if statement, but you need to have checks if you want solid code:
if(is_uploaded_file($_FILES['image']['tmp_name'])){
$folder = "upload/";
$file = basename( $_FILES['image']['name']);
$full_path = $folder.$file;
if(move_uploaded_file($_FILES['image']['tmp_name'], $full_path)) {
echo "succesful upload, we have an image!";
//PDO
$dbc = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "INSERT INTO students( image ) VALUES( :image)";
$stmt = $dbc->prepare($query);
$stmt->bindParam(':image', $full_path);
$results = $stmt->execute();
if($results){
echo "Insert successful!";
}else{
echo "Insert failed!";
}
} else {
echo "upload received! but process failed";
}
}else{
echo "upload failure ! Nothing was uploaded";
}
Few things I would like to point out:
# suppress error, you don't want that when you troubleshoot, even in
production, you still want to be aware of the error.
You should enable error reporting
You didn't check if php script receives the image upload.
The use of file_get_contents is unclear in this case
You don't make use of the $image* variables ? ....
I have a file upload page that works but I'm trying to do some error alerts to choose if you want to replace or not.
This is my php file that does the upload
<?php
require ("connect.php");
$filename = "docs/".$_FILES['datafile']['name']."";
$d=explode(".",$_FILES['datafile']['name']);
if (file_exists($filename)) {
echo "<script>alert('Full dump for ".$d[0]." already exists.')</script>";
$error = 1;
} else {
$target_path = "docs/";
$target_path = $target_path . basename( $_FILES['datafile']['name']);
if(move_uploaded_file($_FILES['datafile']['tmp_name'], $target_path))
{
echo "The file ". basename( $_FILES['datafile']['name'])." has been uploaded";
$error = 0;
}
else
{
echo "There was an error uploading the file, please try again!";
$error = 1;
}
}
if ($error != 1)
{
$r1 = mysql_query("insert into full_dump (file_name) values ('".$_FILES['datafile']['name']."')")or die(mysql_error());
$file1 = "docs/".$_FILES['datafile']['name']."";
$lines = file($file1);
$count = count($lines);
$fp = fopen("docs/".$_FILES['datafile']['name']."","r");
$data=fread($fp,filesize("docs/".$_FILES['datafile']['name'].""));
$tmp=explode ("\n", $data);
for ($i=0; $i<$count; $i++)
{
$a=$tmp[$i];
$b=$i+1;
$r2 = mysql_query("update full_dump set field_".$b."='".$a."' where file_name='".$_FILES['datafile']['name']."'")or die(mysql_error());
}
echo"</br>";
echo "Uploading Complete</br>";
echo "Uploaded File Info:</br>";
echo "Sent file: ".$_FILES['datafile']['name']."</br>";
echo "File size: ".$_FILES['datafile']['size']." bytes</br>";
echo "File type: ".$_FILES['datafile']['type']."</br>";
}
?>
What I want to have is instead of
if (file_exists($filename)) {
echo "<script>alert('Full dump for ".$d[0]." already exists.')</script>";
$error = 1;
}
to have an alert if I would like to replace the file or not. If it's yes it would replace the file, delete the old record in the db and insert the new record. I it's no don't do nothing...or show a message "canceled by user". Could I have $error to be assigned a value for YES or NO on user choosing or not to replace?
UPDATE
This is the form page for upload.
<html>
<head>
<script language="Javascript">
function fileUpload(form, action_url, div_id) {
// Create the iframe...
var iframe = document.createElement("iframe");
iframe.setAttribute("id", "upload_iframe");
iframe.setAttribute("name", "upload_iframe");
iframe.setAttribute("width", "0");
iframe.setAttribute("height", "0");
iframe.setAttribute("border", "0");
iframe.setAttribute("style", "width: 0; height: 0; border: none;");
// Add to document...
form.parentNode.appendChild(iframe);
window.frames['upload_iframe'].name = "upload_iframe";
iframeId = document.getElementById("upload_iframe");
// Add event...
var eventHandler = function () {
if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
else iframeId.removeEventListener("load", eventHandler, false);
// Message from server...
if (iframeId.contentDocument) {
content = iframeId.contentDocument.body.innerHTML;
}
else if (iframeId.contentWindow) {
content = iframeId.contentWindow.document.body.innerHTML;
}
else if (iframeId.document) {
content = iframeId.document.body.innerHTML;
}
document.getElementById(div_id).innerHTML = content;
// Del the iframe...
setTimeout('iframeId.parentNode.removeChild(iframeId)', 250);
}
if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
// Set properties of form...
form.setAttribute("target", "upload_iframe");
form.setAttribute("action", action_url);
form.setAttribute("method", "post");
form.setAttribute("enctype", "multipart/form-data");
form.setAttribute("encoding", "multipart/form-data");
// Submit the form...
form.submit();
document.getElementById(div_id).innerHTML = "Uploading...";}
</script>
</head>
<body>
<form enctype=\"multipart/form-data\" method=\"POST\">
<input type="file" name="datafile" />
<input type="button" value="upload" onClick="fileUpload(this.form,'file_upload.php','upload'); return false;" >
<div id="upload"></div>
</form>
<?php
require("connect.php");
$result = mysql_query("SELECT * FROM full_dump")or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "Job number: ".$row['file_name']."</br>";
}
?>
you should do this with ajax... when you will send ajax request you will check if file exist or not .. if yes return eg -1 and ask user for relapsing ...
Enjoy :)
instead of using upload code on same page. do one thing, upload file by using ajax request. then check on backend site file is aleady exist or not and according to that show message as you like