upload file fails

upload file fails

by Ye Chen -
Number of replies: 19

I upgraded moodle from 1.71 to 1.8 and also 1.72, both verstion has problem with upload file.

When I upload file, it says no file found, but in 1.71, it works fine.

Any suggestion?

Thanks

Ye

Average of ratings: -
In reply to Ye Chen

Re: upload file fails

by Mauno Korpelainen -

It could be just slashargument setting - unselect slasharguments

http://moodle.org/mod/forum/discuss.php?d=69325

In reply to Mauno Korpelainen

Re: upload file fails

by Ye Chen -

the upload file fails are due to the datadirectory changes. Our server is Mac OSX 10.4, working like unix.

I accidently deleted the default datadirectory moodledata, all the moodle site files are there, database is there.

We have back up server facility each day. So I got back the moodledata directory from the back up server.

However, when I go to moodlesite , it is said session time out. Then I checked the backup files, all the sessions file under sessions directory, the modified data is the time when it got back up. So I can not use the back up moodledata. What I have to do is to run a new installation, but connecting the same database, all my user information and others are kept.

The problem is those uploaded file in the data directory. Before I copy those uploaded file to moodledirectory, the upload file function works okay. Once I copied the uploaded file, the upload file function doesn't work, always say no file is found. I am pretty sure it is the backup file may change original file mode either the owner or modified date. 

The only way I can do is to delete those uploaded file, so the upload function can work, and I have to upload each file again. Which I don't want to do this way.

Do you have any idea how to fix this problem?

thanks.

In reply to Ye Chen

Re: upload file fails

by Mauno Korpelainen -

OK. I read these other messages you have sent. When you move your site you need to copy both moodledata folder and database (mysql dump) + config.php with changes you made. You need to use file admin/replace.php after mysql dump or notepad before mysql dump to replace old datadirectory addresses in links with new ones. You could also use moodle course backup/restore feature to copy single courses to a fresh install (then you don't need to copy moodledata folder and database at all)

If you install moodle first and try to copy moodledata folder over old one links are not correct in database and if you copy database without moodledata folder files are missing (links point to wrong place)

You also need to give moodledata folder and all subfolders permissions to read and write - they may as well be 777 permissions. If you still get problems with sessions you may also set dbsessions to 1 in table mdl_config (database) to use database sessions or check that php is handling sessions correctly (session save path is correct). Usually it is just permission problem in moodledata folder.

If you have prolems with pdf file errors you could check from config.php that there is nothing after last ?> (no empty rows etc)

In reply to Mauno Korpelainen

Re: upload file fails

by Ye Chen -

Hello, Mauno,

I very appreciate your help and patience for my so many questions. I followed your instruction, it did not work. I am afraid I may misunderstand your instruction. Following is what I did.

My old server name called like oldserver.com , the root directory is called moodleroot, the moodledata folder is inside the moodleroot.. My new server name called like newserver.com

1. I dumped the database to backup.dump, I am using postgres.

2. Copy the whole directory moodleroot and backup.dump to the new server.

3. Create an empty database called "newdb", restore all the data in backup.dump to newdb.

4. make two changes in the config.php, $CFG->wwwroot="newserver.com", and dbname is set to newdb.

5. run newserver.com/admin/replace.php, then the login/index.php is called, I gave login name and password.

The problem is coming from here. It is supposed to go to newserver.com/index.php, instead, it comes to the same error message I listed in one of my post. see below.

Is there anything wrong I did the step by step?

Thanks

Max OS X Server

Welcome to your website!

This page is just a placeholder. To publish your site, place your HTML and image files in the following directory:

/Library/WebServer/Documents/

Be sure to name your main page "index.html" and it will become the default page for visitors.

In reply to Ye Chen

Re: upload file fails-more information

by Ye Chen -

Mauno,

Just found more information regarding my previous post. I followed your instruction, it worked until to the newserver.com/, it is supposed to call index.php, but it showed the error message. I have to manually put newserver.com/index.php, it will work.

So do you know where goes wrong?

The apache and php settings should be okay. Because on the same server, I have another copy of moodle , just connecting different database, if I switch to that copy, it works okay, no problem.

The only difference of the two copies is one is original located in the server. One is the copy from another server.

The reason I want to figure out is in the future, I may need to move moodle site between develop server and production server.

Thanks

Ye

In reply to Ye Chen

Re: upload file fails-more information

by Richard Enison -

YC,

Are you sure your web server at the new location is configured to accept index.php as a default document name as well as index.html?

RLE

In reply to Richard Enison

Re: upload file fails-more information

by Ye Chen -

Richard,

I did not set up the web server. However, as I said I had two copies of moodle systems on the same web server. One is originally installed on this web server, one is copied from another server. The config.php in the two copies (folders) are same except each connects to different database.

When I test the copy originally installed on this web server, I just name the folder name as the documentroot defined in apache config file, it works fine and can recognize index.php.

When I test the copy from another server, I rename the folder above to something else, and name the copy from another server as the documentroot, for this, it doesn't recognize index.php.

I think the two copies are using the same web server, if it works for one, it should work for another. So it should not be the problem of web server settings.

Am I right?

In reply to Ye Chen

Re: upload file fails-more information

by Richard Enison -

YC,

Not necessarily. I am not familiar with Mac Web Server, but I know that with Apache there can be a DirectoryIndex directive for one directory specifying a default document of index.php for one directory but not for another. That could be the kind of thing that's going on with your situation.

BTW, have you looked into MK's issue about permissions?

RLE

In reply to Ye Chen

Re: upload file fails-more information

by Mauno Korpelainen -

Ye,

dataroots can't be the same in both of your sites if you have your moodledata folder inside your moodle folders. That must be the reason. Could you attach an example about your config.php files from that working and non working moodle?

In reply to Mauno Korpelainen

Re: upload file fails-more information

by Ye Chen -

Mauno,

Here are the two config.php files, one I named config-right.php, one I named config-problem.php, the right one is working one.

config-right.php in the folder called myroot, inside myroot, are all moodle php files. The datafolder called myfiles. For this settings, myfiles is outside myroot.

config-problem.php is in the folder called myroot-remote, inside myroot-remote are all moodle php files copied from other server. the datafolder called myfiles, but it is inside myroot-remote.

If you check the two config.php files, only two things are different, data directory and db name.

When I test the copies from other server, I rename the local copy one from myroot to myroot-local. Then I rename myroot-remote to myroot.

the datafolder myfiles, I already change permission to 777. I did chmod -r 777 myfiles, so it changes every folder and files inside to 777.

Thanks

Ye

In reply to Ye Chen

Re: upload file fails-more information

by Mauno Korpelainen -

Hi Ye,

the main problem is that you need two different www addresses (wwwroots), two different databases (or different prefix for tables), two different dirroots (same as wwwroot) and two different dataroots.

I will send you a message later, I am right now a little busy...

In reply to Mauno Korpelainen

Re: upload file fails-more information

by Mauno Korpelainen -

No, I was wrong. You have done everything (that you discribed in previous message) right. If the reason is not permissions or config.php or slasharguments we must find the next possible reason...

In reply to Mauno Korpelainen

Re: upload file fails-more information

by Richard Enison -

MK,

What is there to find? I still haven't seen anyone say it is not a DirectoryIndex type problem. YC said it works if you specify index.php, but if you leave out the filename from the URL, you get an error msg. complaining that index.html is missing. What else could it be???

RLE

In reply to Richard Enison

Re: upload file fails-more information

by Mauno Korpelainen -

No, if you browse http://act-dev.med.virginia.edu:16080/

there is no problem at all with index.php

That error message could follow error page "HTTP 404 - File not found"  and redirection after that.

Common reasons for this error are:

• The requested file has been renamed.
• The requested file has been moved to another location and/or deleted.
• The requested file is temporarily unavailable due to maintenance, upgrades, or other unknown causes.
• The requested file does not exist.
• A virtual directory is mapped to the root of a drive on another server.

But...I have no idea what it is. Some .htaccess file??? Some corrupted file? Different version of moodle?

In reply to Mauno Korpelainen

Re: upload file fails-find the answer

by Ye Chen -

Mauno and Richard,

First of all, thanks to all of your help. I finally found the answer. I compared the two folders, and found the folder gave me problem has a file called index.html, so it calls index.html instead of index.php, I don't how when and how that html created. That html file has the error message I posted. I rename that index.html to index2.html, everything works okay.

I very very appreciate all your response and especially your time. Although I don't know how that html file was created.

Thanks again

Ye

In reply to Ye Chen

Re: upload file fails-find the answer

by Mauno Korpelainen -

Great!

So it was DirectoryIndex after all just as you suggested, Richard.smile

If index.html is before index.php in DirectoryIndex it is loaded first as a default document.

In reply to Mauno Korpelainen

Re: upload file fails-find the answer

by Richard Enison -

MK,

Thank you.

What I was going to say if the answer had not been found is:

If the problem were any of the things you listed in your previous post, would it have worked ok when the filename index.php was included in the URL as YC had reported it did?

Just a thought to keep in mind the next time a similar problem rears its ugly head.

RLE

In reply to Richard Enison

Re: upload file fails-find the answer

by Mauno Korpelainen -

I really was wide-eyed with surprise when my logic did not match at all. Sometimes it is just hard to know the right strings to pull. big grin

In reply to Ye Chen

Re: upload file fails-more information

by Mauno Korpelainen -

I was going to suggest the same as RLE but...have you checked permissions of moodledata folders and subfolders. When you copy them you need to give permissions to read and write (or even 777). It could be possible that your server redirects "page not found" messages to one page... or $CFG->dataroot and $CFG->dirroot may be wrong.

It's the same with sessions: you need to give folder moodledata/sessions permissions to read and write. Sometimes you also need to change ownership of the session directory to apache:

chown apache:apache /yourdir/moodledata/sessions

And if your fresh moodle is working ok, you may always use course backup in moodle course menu to backup each course separately and move them to new server from course (or site) menu restore.