Reply
file upload script
Old 05-05-2008, 05:56 PM file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
i see the error below when i try uploading a file to my website,can someone help me out..thanks;

Warning: mkdir(/resume): Read-only file system in /home/www/recruitment.parkerituk.com/homework.php on line 22

Warning: move_uploaded_file(/resume/ituk.doc): failed to open stream: No such file or directory in /home/www/recruitment.parkerituk.com/homework.php on line 27

Warning: move_uploaded_file(): Unable to move '/tmp/phpO3ZLMI' to '/resume/ituk.doc' in /home/www/recruitment.parkerituk.com/homework.php on line 27

find below my php code (homework.php):

<form action="homework.php" enctype="multipart/form-data" method="post">
Last Name:<br /> <input type="text" name="name" value="" /><br />
Homework:<br /> <input type="file" name="homework" value="" /><br />
<p><input type="submit" name="submit" value="Submit Notes" /></p>
</form>

<?php

# Set a constant
define ("FILEREPOSITORY","/resume");

if (isset($_FILES['homework'])) {

if (is_uploaded_file($_FILES['homework']['tmp_name'])) {

if ($_FILES['homework']['type'] != "application/msword") {
echo "<p>Homework must be uploaded in WORD format.</p>";
} else {
/* Format date and create daily directory, if necessary. */
$today = date("m-d-Y");
if (! is_dir(FILEREPOSITORY)) {
mkdir(FILEREPOSITORY);
}

/* Assign name and move uploaded file to final destination. */
$name = $_POST['name'];
$result = move_uploaded_file($_FILES['homework']['tmp_name'], FILEREPOSITORY."/"."$name.doc");

/* Provide user with feedback. */
if ($result == 1)
echo "<p>File successfully uploaded.</p>";
else
echo "<p>There was a problem uploading the homework.</p>";
}
}
}
?>


parkerproject is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 05-05-2008, 06:24 PM Re: file upload script
Average Talker

Posts: 15
Name: Levi
For the first error you need to make sure the folder the files are being uploaded to is set to allow writing by users. In fireftp or any ftp program you should be able to right click and go to properties and it will show the permissions for the folder.
Levi_ is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008, 06:24 PM Re: file upload script
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
PHP Code:
define ("FILEREPOSITORY","/resume"); 
This is your error.
You are trying to create a directory "/resume" at the root of the server filesystem, not on the root of your web site.

If you are using apache, you can get the mapping to the web site root via
PHP Code:
define ("FILEREPOSITORY",$_SERVER['DOCUMENT_ROOT']."/resume"); 
This should resolve your problem
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 02:38 PM Re: file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
i still got problem,the script is not uploading file to the specified folder:
do i need to change anything in this code:

define ("FILEREPOSITORY",$_SERVER['DOCUMENT_ROOT']."/resume");

because my site is a sub-domain,so am confused how to mapp it,something like this [parker/recruitment]

thanks for your reply
parkerproject is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 04:30 PM Re: file upload script
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
In some rare case, the DOCUMENT_ROOT can be null, which would lead to the same error as previously.
Can you print the value of the target path ?
PHP Code:
echo "<pre>".FILEREPOSITORY."</pre>"
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 05-08-2008, 09:49 AM Re: file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
i have decided to use another upload script..and is working fine
i was wondering ,if i want to provide a user with a link to its CV in the folder,so that a user can always click on a link to open his current cv ..how can i do that

THANKS
parkerproject is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to file upload script
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.16269 seconds with 14 queries