04-14-2023, 10:11 PM
I've created a file upload script, and it doesn't seem to be working. Here's my code. I'm wondering if there's something that has to do with ehcp. I asked a couple of php guys and they don't know so it might be php settings. I saw something when I searched, but I still don't understand it. Here's the code.
<?php
require('header.php');
require('links.php');
$name = mysql_real_escape_string($_POST['file']);
$url = mysql_real_escape_string($_POST['file']);
$filename = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
$sql = "insert into books set name='$name', url='$url'";
if(isset($_POST['submit'])) {
if($error > 0) {
die("Error uploading file! Code $error.");
}else{
move_uploaded_file($temp,"/center/resources/books/".$filename);
mysql_query($sql);
}
}
?>
<form method='post' enctype='multipart/form-data'>
Book Name<input type="text" name="name"></br>
File<input type="file" name="file"></br>
<input type="submit" name="submit" value="Upload">
</form>
Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.
<?php
require('header.php');
require('links.php');
$name = mysql_real_escape_string($_POST['file']);
$url = mysql_real_escape_string($_POST['file']);
$filename = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
$sql = "insert into books set name='$name', url='$url'";
if(isset($_POST['submit'])) {
if($error > 0) {
die("Error uploading file! Code $error.");
}else{
move_uploaded_file($temp,"/center/resources/books/".$filename);
mysql_query($sql);
}
}
?>
<form method='post' enctype='multipart/form-data'>
Book Name<input type="text" name="name"></br>
File<input type="file" name="file"></br>
<input type="submit" name="submit" value="Upload">
</form>
Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.