473,666 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newbie Upload Script Help

2 New Member
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_f ile(/uploads/011bc55e70e56ea 8a320e7182166d6 7a.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_f ile(): Unable to move '/tmp/phpOuv94S' to '/uploads/011bc55e70e56ea 8a320e7182166d6 7a.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 1576
grozanc
2 New Member
I got everything working, thanks anyway.
May 20 '07 #2
Atli
5,058 Recognized Expert Expert
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
2918
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 upload files, like this: copy ($myfile, $uploadfolder . "/" . $myfile_name); Everything works fine, it can process large files and everything, but i need to make sure that people only upload pictures, so i change
3
2885
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 have looked up the error, and added more time to the script (up to 10 minutes). Didn't help.
9
3824
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 site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
7
441
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 then max. The folder I'm trying to upload files to is ./ispit1. I always get the "wrong" echo from the script when I run debug in my editor and when I run it in my browser (firefox) I get the following message: "The requested URL /ispit/__URL__...
9
3887
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 works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
21
34389
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
3
4500
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 my objective is this that when i uplod a file it should be desply on same page with ajax uplod after when i refresh page this should be not remains longer and on clicking other image its replase previous image plz help how i can do this the...
1
3949
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 my objective is this that when i uplod a file it should be desply on same page with ajax uplod after when i refresh page this should be not remains longer and on clicking other image its replase previous image plz help how i can do this the...
5
3278
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 _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.