cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading to web space via Form & PHP

N/A

Uploading to web space via Form & PHP

Hi,
I've seen an old discussion about this but it remained unresolved. I have a working PHP script to upload small images to the CGI server via a form. I have set the path to that described by 'pwd', and set full permissions on the relevant folder.

However this doesn't work, nothing is uploaded. No PHP error is displayed. The previous discussion talked about a PHP log somewhere that said words to the effect of "method not allowed".

Has anyone on Force9 got file uploads working? What did you have to do to get it to work?

Many thanks.

11 REPLIES
N/A

RE: Uploading to web space via Form & PHP

> Hi,
> I've seen an old discussion about this but it remained unresolved. I have a working PHP script to upload small images to the CGI server via a form. I have set the path to that described by 'pwd', and set full permissions on the relevant folder.
>
> However this doesn't work, nothing is uploaded. No PHP error is displayed. The previous discussion talked about a PHP log somewhere that said words to the effect of "method not allowed".
>
> Has anyone on Force9 got file uploads working? What did you have to do to get it to work?
>
> Many thanks.
>
>

Not sure if this is related, but when I ran a forum off my CGI space, no users could upload anything (via the upload feature) unless their service provider was Force 9. Never did get to the bottom of that problem either.
N/A

RE: Uploading to web space via Form & PHP

Yeah, I thought about that being a problem, but then I should be able to upload to the server, seeing that I am dialling up through F9. The previous discussion in 2001 suggested that you should even be able to allow uploads to your regular Homepages space (which is far preferable given the space restrictions on CGI) but it wasn't resolved.

Shame there's no tech support for PHP. Might have to do a random search around all Force9 sites and see if anyone's managed to do it. Failing that, anyone know an alternative ISP that does allow it?

Cheers,
Graham

> > Hi,
> > I've seen an old discussion about this but it remained unresolved. I have a working PHP script to upload small images to the CGI server via a form. I have set the path to that described by 'pwd', and set full permissions on the relevant folder.
> >
> > However this doesn't work, nothing is uploaded. No PHP error is displayed. The previous discussion talked about a PHP log somewhere that said words to the effect of "method not allowed".
> >
> > Has anyone on Force9 got file uploads working? What did you have to do to get it to work?
> >
> > Many thanks.
> >
> >
>
> Not sure if this is related, but when I ran a forum off my CGI space, no users could upload anything (via the upload feature) unless their service provider was Force 9. Never did get to the bottom of that problem either.

N/A

RE: Uploading to web space via Form & PHP

Don't personally know of any other ISPs, I ended up going for a separate hosting company (XCalibre), but I did really need to go that way for a couple of clients sites that I was moving away from their old hosts. I still (obviously) use Force 9 as an ISP, and may actually start using my CGI account again when they upgrade to the new platform, as I've still got one of my personal domains pointing to my F9 webspace.
N/A

RE: Uploading to web space via Form & PHP

This is how I have done it - just checked and it works first time. Script is set to allow gif and jpegs - adjust accordingly. Have fun. Don't forget to chmod 777 your directory.

<?php

if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",100000);
define("DESTINATION_FOLDER", "../uploads/");
define("no_error", "upload_success.php");
define("yes_error", "upload_error.php");
$_accepted_extensions_ = "gif,jpg";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}

$_file_ = $HTTP_POST_FILES['myfile'];
if(is_uploaded_file($_file_['tmp_name']) && $HTTP_POST_FILES['myfile']['error'] == 0){
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "invalid file size";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Not a Valid extension";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Not valid destination folder";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" enctype="multipart/form-data" action="upload_file.php">

Select a file to upload! <input type="file" name="myfile"><br>
<input type="submit" value="Upload!">
</form>

</body>
</html>


> Hi,
> I've seen an old discussion about this but it remained unresolved. I have a working PHP script to upload small images to the CGI server via a form. I have set the path to that described by 'pwd', and set full permissions on the relevant folder.
>
> However this doesn't work, nothing is uploaded. No PHP error is displayed. The previous discussion talked about a PHP log somewhere that said words to the effect of "method not allowed".
>
> Has anyone on Force9 got file uploads working? What did you have to do to get it to work?
>
> Many thanks.
>
>



--
N/A

RE: Uploading to web space via Form & PHP

Wow! Thanks. I had to remove the stuff about headers as it clashed with my existing scripts but now it works perfectly. It's possible that my problem was as simple as using an absolute path rather than the relative one you used, but I'm not sure.

On an irrelevant note, I was using ambiguous date formats such as 2002-00-00, allowable in MySQL 3.23 but not in 3.22. However as I wasn't actually doing calculations on these dates I was able to convert them to a varchar field and use them with only slight script changes.
N/A

RE: Uploading to web space via Form & PHP

No problem - at least you got it working.

Martin

> Wow! Thanks. I had to remove the stuff about headers as it clashed with my existing scripts but now it works perfectly. It's possible that my problem was as simple as using an absolute path rather than the relative one you used, but I'm not sure.
>
> On an irrelevant note, I was using ambiguous date formats such as 2002-00-00, allowable in MySQL 3.23 but not in 3.22. However as I wasn't actually doing calculations on these dates I was able to convert them to a varchar field and use them with only slight script changes.

re-create-it
Grafter
Posts: 55
Registered: 13-08-2007

RE: Uploading to web space via Form & PHP


> Shame there's no tech support for PHP. Might have to do a random search around all Force9 sites and see if anyone's managed to do it. Failing that, anyone know an alternative ISP that does allow it?
>

After playing for a while and trying to upload files on F9 I gave up. The other annoying thing is the space restriction that you mention, which meant I was running a dual server setup with all my images on the homepages server and scripts on the cgi server. Very confusing.

I now host my site elsewhere (blackfoot.co.uk) but am still very happy with the dial-up from F9. An independant host allows remote access via any connection and the one I use also 'bundles' a very comprehensive admin package including a file manager and various admin tools on-line.

--
Phil Reed
[re-create] | www.re-create-it.co.uk
N/A

Uploading to web space via Form & PHP

no matter what i do for any php script i get this:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


so i gave up using php a long time ago!
N/A

Shame

Shame because you're losing out.

Make sure your PHP files are not in the cgi bin and that you are uploading to cgi space (shell.force9.net) and not the ordinary web space on F9.

Martin
N/A

Uploading to web space via Form & PHP

:shock: :shock: :shock: :shock: :shock: :shock: :shock:

i owe you one

wow

Nowhere have i read that you dont put the php files in the cgi-bin directory... WOW... you have just my life SOOO much easier. heh, check out what ive got working already Smiley a flash message board TongueTongue

http://cgi.unique.force9.co.uk/Forum/Forum.html

thanks, a lot!!!

Andy Burton
N/A

Uploading to web space via Form & PHP

No problem, I love a happy ending.

Martin