| | |
file upload issues
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I'm trying to upload .js files onto my sever. This is the code:
I get this error:
Anyone know what a possible problem might be?
PHP Syntax (Toggle Plain Text)
<html> <head> <title>Add Ubiquity Command</title> </head> <body> <form action="add_ubiquity_cmd.php" method="post" enctype="multipart/form-data"> Name: <input type="text" name="name" /><br /> Description: <textarea rows="8" cols="30" name="description"></textarea><br /> JS File: <input type="file" name="file"><br /> <input type="submit" value="Add Command" /><br/> </form> <?php if(isset($_POST["name"])) { $con = mysql_connect("localhost", "usr", "pass"); mysql_select_db("alecbenz_general"); if($_FILES["file"]["error"] > 0) { echo "Error: ".$_FILES["file"]["error"]; } elseif($_FILES["file"]["type"] != "application/x-javascript") { echo "Error: file not a Javascript file"; } elseif(file_exists("../ubiquity/".$_FILES["file"]["name"])) { echo "Error: filename already being used."; } else { if(!(move_uploaded_file($_FILES["file"]["tmp_name"],"/ubiquity/".$_FILES["file"]["name"]))) { $error = error_get_last(); echo "Error uploading file:<br />Type:".$error["type"]."<br />Message:".$error["message"]; } else { echo "File uploaded<br />"; $sql = "INSERT INTO ubiquity_cmds (name,description,js_filename) VALUES(".$_POST["name"].",".$_POST["description"].",".$_FILES["file"]["name"].")"; if(mysql_query($sql,$con)) { echo "Command added"; } else { echo "Error adding command: ".mysql_error(); } } } } ?> </body> </html>
I get this error:
PHP Syntax (Toggle Plain Text)
Error uploading file: Type:2 Message:move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuveovn' to '/ubiquity/cmd_echo.js'
Anyone know what a possible problem might be?
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
My first guess would be that you don't have write permission on the destination directory.
Try turning on the debug messages by putting this at the top of your page:
See if that produces a more helpful error message.
Try turning on the debug messages by putting this at the top of your page:
php Syntax (Toggle Plain Text)
error_reporting(E_ALL); ini_set('display_errors', true);
may be permission error of destination directory
Help as an alias
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
I think I found my problem. For some reason, doing /ubiquity/ doesn't work. I'm under the impression that / would be my public_html directory, and so /ubiquity/ would be public_html/ubiquity/. Anyway, I changed it to ../ubiquity/ (the folder I'm in is also located in public_html), and I don't get an error with the file move.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
On a Linux server, prefixing any path with / will make it start at the root directory.
So your
This is different for URL's, where / will have the browser start at the web root.
Like, for example, if you had an <a> href
So your
/ubiquity/ path would look for a folder called ubiquity directly under the root.This is different for URL's, where / will have the browser start at the web root.
Like, for example, if you had an <a> href
/page.php in a page at www.example.com/path/to/page.html , it would send you to www.example.com/page.php . Last edited by Atli; Sep 17th, 2008 at 4:59 am. Reason: spelling
![]() |
Similar Threads
- Issues w/ file uploads in PHP (PHP)
- Couple annoying issues (Windows NT / 2000 / XP)
- file upload script for music files and video files (PHP)
- OIN issues (Viruses, Spyware and other Nasties)
- Browser Redirect/System Restore Problems/etc.... (Viruses, Spyware and other Nasties)
- [ For Hire ] osCommerce & phpBB Work (Post your Resume)
- Desktop Hijacked and can't find a fix (Viruses, Spyware and other Nasties)
- VX2/F problem along with other issues... (Viruses, Spyware and other Nasties)
- Hijack This Log, please help (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Mail error?
- Next Thread: want to insert the image background
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database date display duplicates dynamic echo email emptydisplayvalue error errors explodefunction file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect regex remote script search securephp server sessions shot sms soap source space sql subscription syntax system table tutorial update upload url validator variable video web xml youtube





