Uploading PDF Problem on Windows!

Alles, was PHP betrifft, kann hier besprochen werden.

Uploading PDF Problem on Windows!

Postby rooomka » 05. November 2008 01:41

I am having serious issues uploading pdf files to my MySql database and into a directory since bringing my code from a Unix system using Apache to a Windows system running Apache. I can still upload images without a problem, the issue is strictly pdf files.

As I stated, this code works fine on my Unix server, but since I installed the XAMPP Package on my laptop, which is running Windows XP Professional, this code is no longer working. The pdf file name is not being inserted into the database and the pdf file is not going into the directory.

I am guessing it has something to do with this line"($file_type == "application/pdf")" or this line"$newfile = "../menus/".$file_name;". Can anyone give a hand on this one?

Here is the code:

<? } else {

//insert record in database

if (is_uploaded_file($file)) {

$badchararray = array(" ","'","\"","$","&","%","-","#");
$file_name = str_replace($badchararray, "_", $file_name);
$file_name = stripslashes(strtolower($file_name));

if ($file_type == "application/pdf") {

$newfile = "../menus/".$file_name;

if (!copy($file, $newfile))
{
print "Could Not Upload Your File.";
exit();
}
}

}

mysql_query("INSERT INTO menus SET title = '$title', file = '$file_name', content = '$content'");
?>
rooomka
 
Posts: 8
Joined: 03. November 2008 20:38
Location: United States

Postby Wiedmann » 05. November 2008 01:50

The pdf file name is not being inserted into the database and the pdf file is not going into the directory.

So you see the message "Could Not Upload Your File." in your browser instead?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Chuck1971 » 05. November 2008 02:52

No, that is what puzzles me. It acts as if everything worked fine and says the upload was successful. It is uploading every other field except for the "file" field.
Chuck1971
 
Posts: 5
Joined: 30. October 2008 15:44

Postby Xardas der Dunkle » 05. November 2008 06:47

Do you use register_globals?
User avatar
Xardas der Dunkle
 
Posts: 482
Joined: 09. March 2008 19:40
Location: /var/www

Postby Wiedmann » 05. November 2008 13:07

No, that is what puzzles me.

Put a:
Code: Select all
echo "here";
exit;

after the first "if {}" and try the script. Then move the code after the next if {} to find out, with if {} is not working correct. (and so on with the pther ifs).

Also verify with a:
Code: Select all
var_dump($varname);

before the if {}, if the value is what you expect.


BTW:
I assume, that you have allready a "error_reporting(E_ALL);" in your script for debugging.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Still needing help!

Postby rooomka » 06. November 2008 23:47

I did use the error script. The only thing the error script pointed out is that I didn't define the variable $action here:

<? if ($action == "") { ?>

When I define the variable, it points that out. Here is that script:

$action = $_POST['action'];

When I comment out my error reporting script, everything but the pdf file goes in the database whether I define the $action variable or not, so I am a little confused.

Got anything else for me?
rooomka
 
Posts: 8
Joined: 03. November 2008 20:38
Location: United States


Return to PHP

Who is online

Users browsing this forum: No registered users and 13 guests