View Single Post
  #1 (permalink)  
Old March 31st, 2010, 09:06 PM
kenj kenj is offline
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chapter 6, Ajax File Manager, error in upload.php file

ISSUE # 1 - error in upload.php file

Chapter 6, upload.php file, the downloaded code,
lines 12 and 13 result in BASEDIR getting concatenated
to the file path twice. This is not correct.
$dir = realpath(BASEDIR . $_POST['dir']);
$target = BASEDIR . $dir . '/' . $_FILES['file']['name'];
You can correct it by removing the string BASEDIR from
line 13, like this.
$dir = realpath(BASEDIR . $_POST['dir']);
$target = $dir . '/' . $_FILES['file']['name'];
After making this fix, it worked for me.

Configuration note: I am using the downloaded code. The
downloaded code has a file named ajax.js which is the
correct filename.
In previous posts in this forum, there were some issues
because the book was referring to the file by
the name helper.js, but it should be ajax.js
Anyway, after I made the above change chapter 6
worked for me. I am in a UNIX/Linux environment.

Now, one more thing. you have to have your php.ini file set up
correctly in order for the uploads to work properly. I
discuss this in a previous post here:
Chap 2 - Avatars and uploading files, (would apply to Chap 6 too)

ISSUE #2 - duplicate file name from chapter 5

Chapter 6 has the following file name.

The problem is chapter 5 has the exact same filename
in the same directory, In my view, the filenames should
be unique across chapters because they are in the same

Last edited by kenj; January 23rd, 2011 at 01:53 AM.. Reason: Changing reference to other post into a link