Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File upload script not working
#1
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.
Reply
#2
I figured the upper code didnt work, so here's an image.
http://img526.imageshack.us/i/screenshot20110218at413.png/

Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.
Reply
#3
Where is the code running at? ie in a domain folder? where are you trying to upload the file to?

Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.
Reply
#4
in the image... I'm trying to upload it from admin to /center/resources/books where /center is a directory right off of the root directory

Restored from old drupal forum, for user uid:3246 username:Stone1555
You may reset your password to access your new account here.
Reply
#5
Ok let me try to explain that better.

this code u have in the pic is in a file called lets say, upload.php. Where is that file located? is it in a domain--

test.com/upload.php =

var/www/vhosts/test/test.com/httpdocs/upload.php?

and the dir your copying to, wheres its path?


var/www/vhosts/test/test.com/httpdocs/center/resources/books

thats just an example of what im looking for. If your trying to put the file somewhere on the server not in a web dir, esp under the same domain as that the script is in, you will have issues.




Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.
Reply
#6
its located in /center/admin/addresource.php

Restored from old drupal forum, for user uid:3246 username:Stone1555
You may reset your password to access your new account here.
Reply
#7
Your solution didn't help. I still receive that error.

Restored from old drupal forum, for user uid:2687 username:ehcpuser
You may reset your password to access your new account here.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)

Online Shopping App
Online Shopping - E-Commerce Platform
Online Shopping - E-Commerce Platform
Feinunze Schmuck Jewelery Online Shopping