473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Newbie Upload Script Help

Hello,

I keep getting the following erorrs when trying to use a PHP/MYSQL upload script. Can anyone tell me what's causing this error? I'm not a programmer, just an MFA student working on his thesis and needs to collect images from several thousand people.

So far I have CMOD 777 the directory that uploads are going into and tried different directories but nothing has worked.

Thanks in advance!

Warning: move_uploaded_file(/uploads/011bc55e70e56ea8a320e7182166d67a.JPG): failed to open stream: No such file or directory in /home/content/g/r/o/grozanc/html/pavementmemoirs/uploads/upload3.php on line 42

Warning: move_uploaded_file(): Unable to move '/tmp/phpOuv94S' to '/uploads/011bc55e70e56ea8a320e7182166d67a.JPG' in /home/content/g/r/o/grozanc/html/pavementmemoirs/uploads/upload3.php on line 42
Error uploading file
Here is the code to the script I'm trying to run:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Upload File To MySQL Database</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <style type="text/css">
  6. <!--
  7. .box {
  8.     font-family: Arial, Helvetica, sans-serif;
  9.     font-size: 12px;
  10.     border: 1px solid #000000;
  11. }
  12. -->
  13. </style>
  14. </head>
  15.  
  16. <body>
  17. <?
  18. // you can change this to any directory you want
  19. // as long as php can write to it
  20. $uploadDir = '/uploads/';
  21.  
  22.  
  23. if(isset($_POST['upload']))
  24. {
  25.     $fileName = $_FILES['userfile']['name'];
  26.     $tmpName  = $_FILES['userfile']['tmp_name'];
  27.     $fileSize = $_FILES['userfile']['size'];
  28.     $fileType = $_FILES['userfile']['type'];
  29.  
  30.     // get the file extension first
  31.     $ext      = substr(strrchr($fileName, "."), 1); 
  32.  
  33.     // generate the random file name
  34.     $randName = md5(rand() * time());
  35.  
  36.     // and now we have the unique file name for the upload file
  37.     $filePath = $uploadDir . $randName . '.' . $ext;
  38.  
  39.     // move the files to the specified directory
  40.     // if the upload directory is not writable or
  41.     // something else went wrong $result will be false
  42.     $result    = move_uploaded_file($tmpName, $filePath);
  43.     if (!$result) {
  44.         echo "Error uploading file";
  45.         exit;
  46.     }
  47.  
  48.     include 'library/config.php';
  49.     include 'library/opendb.php';
  50.  
  51.     if(!get_magic_quotes_gpc())
  52.     {
  53.         $fileName  = addslashes($fileName);
  54.         $filePath  = addslashes($filePath);
  55.     }  
  56.  
  57.     $query = "INSERT INTO upload2 (name, size, type, path ) ".
  58.              "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
  59.  
  60.     mysql_query($query) or die('Error, query failed : ' . mysql_error());                    
  61.  
  62.     include 'library/closedb.php';
  63.  
  64.     echo "<br>File uploaded<br>";
  65. }        
  66. ?>
  67. <form action="" method="post" enctype="multipart/form-data" name="uploadform">
  68.   <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
  69.     <tr> 
  70.       <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="200000000"><input name="userfile" type="file" class="box" id="userfile">
  71.          </td>
  72.       <td width="80"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td>
  73.     </tr>
  74.   </table>
  75. </form>
  76. </body>
  77. </html>
  78.  
May 20 '07 #1
2 1543
I got everything working, thanks anyway.
May 20 '07 #2
Atli
5,058 Expert 4TB
I got everything working, thanks anyway.
Hi, grozanc, and welcome to TSDN.

I'm glad to hear you have solved your problem.
Would you be willing to share your solution with us?
May 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tihon | last post by:
Hello! I again need your help, just can't understand whats going on. Got this upload pictures form and it's having problem handling large files (~1.5 - 2 MB). Everything works fine if i just...
3
by: Martin | last post by:
I have an ASP form that uploads files to our server. When I upload small files, it works great. But larger files like (2.5mb), I get: Active Server Pages error 'ASP 0113' Script timed out I...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: ljuljacka | last post by:
I'm just trying to run a fileupload script from the manual, just to see how it works, and it won't. I've checked if file upload is enabled and it is. Also, the file I'm trying to upload is smaller...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
3
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.