3 Replies - 531 Views - Last Post: 12 September 2009 - 10:16 AM Rate Topic: -----

#1 d.buckner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 04-December 08

Problem with uploading images

Posted 11 September 2009 - 08:37 AM

I am trying to write a page that allows users to upload images to my web server (family website), The code below works from my machine accessing the site through the web, however I have had others test the site and they are not able to upload anything. What am I doing wrong?

below is my code that is working on my local machine, it uploads the photo, and creates an entry in the database with the filename and title, etc. which I use to access the data on the view page.

Is this a coding problem, or a privilege problem. I think I have the correct privileges set on the folder. I am running Server 2008 with PHP and MySQL.

<?php
include("connect.php");
$date=date('m-d-Y');
$filename=$_POST['title']."_".$date;
$title=$_POST['title'];
$description = $_POST['description'];
$target_path = "uploads/";
$extention = explode(".",$_FILES['uploadedfile']['name']);
$newfilename = $filename.".".$extention[1];
$target_path .=  basename( $newfilename); 


if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
	echo "<br>The file ".  basename( $_FILES['uploadedfile']['name']). 
	" has been uploaded";
   } else{
	echo "<br>There was an error uploading the file, please try again!";
}

$sql="INSERT INTO photos VALUES( NULL , NOW( ) , '$newfilename', '$title', '$description')";
mysql_query($sql,$con);



?>




Is This A Good Question/Topic? 0
  • +

Replies To: Problem with uploading images

#2 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: Problem with uploading images

Posted 11 September 2009 - 09:44 AM

As far as I can see it looks to be fine, but you may have to open up the rights for the file path where you are moving the file to, this can be done using chmod():
chmod($filepath, 0777);
this code grants you full access to the specified file path!

Hope it helps! :)
Was This Post Helpful? 0
  • +
  • -

#3 d.buckner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 04-December 08

Re: Problem with uploading images

Posted 12 September 2009 - 08:04 AM

View PostWimpy, on 11 Sep, 2009 - 08:44 AM, said:

As far as I can see it looks to be fine, but you may have to open up the rights for the file path where you are moving the file to, this can be done using chmod():
chmod($filepath, 0777);
this code grants you full access to the specified file path!

Hope it helps! :)


I am running this on a Windows server, and have full permissions granted on the upload folder.
Was This Post Helpful? 0
  • +
  • -

#4 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: Problem with uploading images

Posted 12 September 2009 - 10:16 AM

ok, how big files are you trying to upload? and how big are they allowed to be in your php configuration?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1