Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> File Uploading Issues
kvarnerexpress
post Sep 19 2005, 10:07 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



i have never tried to have files uploaded and i am still not able to do so. here is the codes that i am using right out of the php manual and it still isnt working. i have also listed the warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder set up on my server as "uploads". i am however not sure if i have a default temp folder on my server. can anyone help me figure out what i am not doing correctly or what my next step is?

this is the form that i am using:
html Code:

CODE
<form enctype="multipart/form-data" action="upload.php" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
   Choose a file to upload: <input name="userfile" type="file" />
   <input type="submit" value="Upload File" />
</form>



this is the php page "upload.php"
php Code:


CODE
#

#
<?php
#
$uploadDir = '/uploads/';
#
$uploadFile = $uploadDir . $_FILES['userfile']['name'];
#
print "<pre>";
#
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
#
{
#
   print "File is valid, and was successfully uploaded. ";
#
   print "Here's some more debugging info:\n";
#
   print_r($_FILES);
#
}
#
else
#
{
#
   print "Possible file upload attack!  Here's some debugging info:\n";
#
   print_r($_FILES);
#
}
#
print "</pre>";
#



this is the resulting error:
Code:

CODE
Warning:  move_uploaded_file(/uploads/golf.jpg): failed to open stream: No such file or directory in /home/jesokcc/public_html/upload.php on line 5

Warning:  move_uploaded_file(): Unable to move '/tmp/php72OLgu' to '/uploads/golf.jpg' in /home/jesokcc/public_html/upload.php on line 5
Possible file upload attack!  Here's some debugging info:
Array
(
   [userfile] => Array
       (
           [name] => golf.jpg
           [type] => image/pjpeg
           [tmp_name] => /tmp/php72OLgu
           [error] => 0
           [size] => 9802
       )

)


Thanks,kvarnerexpress
Go to the top of the page
 
+Quote Post
arboc7
post Sep 20 2005, 12:26 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 123
Joined: 5-September 05
Member No.: 11,522



It looks like your code is valid and should work. On what kind of server are you running this script? (i.e., Linux, Windows, et cetera) You may simply have a permissions problem that either you or the server administrator needs to change. That's all of which I can think!

Hope this helps!!

Go to the top of the page
 
+Quote Post
Spectre
post Sep 26 2005, 05:23 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



Try changing $uploadDir = '/uploads/'; to $uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';

As it is now, PHP will try and copy the uploaded file into the '/uploads' directory on the root of the server - not the root of your site, which is probably something like '/www/username/public_html/'.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Script: Php Jukebox(4)
  3. Uploading From Url(9)
  4. I Need Help With File Edit In Php(6)
  5. Include File.php?id=something(13)
  6. Logging Dowload Files From Your Server Onto A Html File(1)
  7. File String Delete?(2)
  8. Php Writes Into Txt File(8)
  9. File In Database(1)
  10. File Format Unknown! (wap)(6)
  11. Display Random File In A Directory(9)
  12. Sql Selection Issues(1)
  13. Help Needed With Directory/file Listing Code Infinite Loop(5)
  14. Uploading A Photo...(3)
  15. Help Php: How To Load String From Text File (solved)(9)
  1. Php Help Needed Including File In A Page.(2)
  2. Edit .txt File In Ftp Via Webpage(2)
  3. [php]simple Flat File Text Manipulator(3)
  4. <?php ?> Unique Visitors Script(2)
  5. File Upload(1)
  6. Need Help Uploading Php(8)
  7. No File Extension(3)
  8. Php And Flash Image Gallery(5)
  9. File Checker-how To Check File Whith Html Through Html?(2)
  10. Php Sessions And Post Variables Issues(1)
  11. Updating Php File Through A Web Form(5)
  12. Need Some Help In File Browser(8)
  13. Php Configuration File(16)


 



- Lo-Fi Version Time is now: 8th September 2008 - 09:01 AM