473,729 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not able to upload a file into my webserver :(:(:(

222 New Member
Dear sirs,


It is shame to me to say that I have been 1 week working in this problem and it is not working.
I am getting this error while I am uploading a file using my website.

Warning: copy( /home/wasstech/attachement/juj.doc) [function.copy]: failed to open stream: Operation not permitted in /home/wasstech/public_html/send.php on line 9
Error

Expand|Select|Wrap|Line Numbers
  1.  
  2. <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  3. <tr>
  4. <form action="send.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  5. <td>
  6. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  7. <tr>
  8. <td><strong>Single File Upload </strong></td>
  9. </tr>
  10. <tr>
  11. <td>Select file
  12. <input name="ufile" type="file" id="ufile" size="50" /></td>
  13. </tr>
  14. <tr>
  15. <td align="center"><input type="submit" name="Submit" value="Upload" /></td>
  16. </tr>
  17. </table>
  18. </td>
  19. </form>
  20. </tr>
  21. </table>
  22.  
my action code is send.php


Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. //set where you want to store files
  3. //in this example we keep file in folder upload
  4. //$HTTP_POST_FILES['ufile']['name']; = upload file name
  5. //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
  6. $path= "/home/wasstech/attachement/".$HTTP_POST_FILES['ufile']['name'];
  7. if($ufile !=none)
  8. {
  9. if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
  10. {
  11. echo "Successful<BR/>";
  12.  
  13. //$HTTP_POST_FILES['ufile']['name'] = file name
  14. //$HTTP_POST_FILES['ufile']['size'] = file size
  15. //$HTTP_POST_FILES['ufile']['type'] = type of file
  16. echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>";
  17. echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
  18. echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
  19. echo "<img src=\"$path\" width=\"150\" height=\"150\">";
  20. }
  21. else
  22. {
  23. echo "Error";
  24. }
  25. }
  26. ?>
  27.  
I am sure that the permission of my folder attachement is 777 and I am 90 % sure of my path


WHAT IS PROBLEM???

please please help me ASAP.

WASSIM S DACCACH
Jun 28 '08 #1
3 1941
Markus
6,050 Recognized Expert Expert
Instead of copy() use move_uploaded_f ile().

$_HTTP_POST_FIL ES is deprecated. Use $_FILES.

90% sure? Needs to be 100%.

Make sure the file doing the upload has priviledges and also the directory where you are saving the file.
Jun 28 '08 #2
wassimdaccache
222 New Member
Dear markusn,

I am writing this code. No error is made but still not uploading my (--> didn't upload error)

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. //set where you want to store files
  3. //in this example we keep file in folder upload
  4. //$HTTP_POST_FILES['ufile']['name']; = upload file name
  5. //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
  6. $path= "/home/wasstech/attachements".$_FILES['ufile']['name'];
  7. if($ufile !=none)
  8. {
  9. if(move_uploaded_file($_FILES['ufile']['name'], $path))
  10. {
  11. echo "Successful<BR/>";
  12.  
  13. //$HTTP_POST_FILES['ufile']['name'] = file name
  14. //$HTTP_POST_FILES['ufile']['size'] = file size
  15. //$HTTP_POST_FILES['ufile']['type'] = type of file
  16. echo "File Name :".$_FILES['ufile']['name']."<BR/>";
  17. echo "File Size :".$_FILES['ufile']['size']."<BR/>";
  18. echo "File Type :".$_FILES['ufile']['type']."<BR/>";
  19. echo "<img src=\"$path\" width=\"150\" height=\"150\">";
  20. }
  21. else
  22. {
  23. echo "Didn't upload ERROR ";
  24. }
  25. }
  26. ?>
  27.  
actually I am newbie on PHP but I would like to learn this famous language now a day.

regards,

WASSIM S DACCACHE
Jun 28 '08 #3
nashruddin
25 New Member
Try this:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $path= "/home/wasstech/attachements/".$_FILES['ufile']['name'];
  3. if(!empty($_FILES['ufile'])) {
  4.   if(move_uploaded_file($_FILES['ufile']['tmp_name'], $path)) { 
  5.     echo "Success";
  6.   } else { 
  7.     echo "Failed";
  8.   }
  9. }
  10. ?>
  11.  
Jun 29 '08 #4

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

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.