Jump to content

[SOLVED] Upload file script


BarneyJoe

Recommended Posts

Hope someone can help with this - it's some code I've used before, and had working fine, but am having problems with another site.

 

In the site it works for, I have a file input :

 

<tr>
<td class="labelcell">Image File Name </td>
<td class="fieldcell"><input type="file" name="Image"></td>
</tr>

 

And then in a validate.php page, the upload code :

 

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

$destpath = '../Photos/' . basename($_FILES['Image']['name']);

if (!move_uploaded_file($_FILES['Image']['tmp_name'], $destpath) ) {
  echo 'Error moving file ' . $_FILES['Image']['tmp_name'] . ' to ' . $destpath;
}
}

 

Which, as I say, works fine.

 

However, in a new site I'm doing, I have the input as :

 

<tr>
<td class="labelcell">Image File Name </td>
<td class="fieldcell"><input type="file" name="ImageLarge"></td>
</tr

>

 

And the upload code in my validation file :

 

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

$destpath = '../jewelleryimages/' . basename($_FILES['ImageLarge']['name']);

if (!move_uploaded_file($_FILES['ImageLarge']['tmp_name'], $destpath) ) {
  echo 'Error moving file ' . $_FILES['ImageLarge']['tmp_name'] . ' to ' . $destpath;
}
}

 

ie, ie matching the input field name, 'ImageLarge', and changing the destination path (double checked) to '../jewelleryimages/'

 

However, when I try to use it, I'm getting the error :

 

Warning: move_uploaded_file(../jewelleryimages/fashion.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/iqzwlvrk/public_html/admin/validate3.php on line 243

 

Where line 243 is

 

if (!move_uploaded_file($_FILES['ImageLarge']['tmp_name'], $destpath) ) {

 

Any idea what I'm missing here?

 

Many thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/69455-solved-upload-file-script/
Share on other sites

Think I've found it - comparing the permissions in the respective control panels, the original is set to 0777, while the new one is still showing as 0755 - changed that, and it's fine.

 

Think I had a mental block about permissions to access the database.

 

Cheers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.