close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

UploadFolder variable difficulties

Thread began 10/17/2009 8:13 am by martin389853 | Last modified 10/19/2009 4:10 am by martin389853 | 2434 views | 7 replies |

martin389853

UploadFolder variable difficulties

I did look to check if there was anything on this but nothing obvious that I could find.

You should be familiar with the code below.

$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "". '$imageFolder' ."",

I have created the $imageFolder variable to hold the whole file link, eg. /images/johnsmithsImages/ where 'johnsmiths' will be another variable. Like this I store everyone's images in their own folder and summon up the link to the upload folder according to the logged-in user.

My problem is simply that no images are going into the folder. There are no errors being displayed like when I type the variable in incorrectly and if I write the exact folder location in, eg.

$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "/images/johnsmithsImages/",

I don't have a problem. Am I writing sucky php? icon11.gif cheers.

Sign in to reply to this post

anonymous

Martin,

Nine times out of ten, these problems are usually something simple... so I will start with simple. Did you remember to set the permissions of the folder once it was created?

If you are creating the folders manually and uploading the folders, you will need to chmod them to something like 0777 so they will have read and write capabilities. If you are allowing the folders to be created on the fly, then the parent folder will have to be assigned the recursive permissions of 0777 so that you can write within the folder and into all the child folders.

Cheers,

Brian

Sign in to reply to this post

martin389853

Originally Said By: martin389853
  ... if I write the exact folder location in, eg.

$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "/images/johnsmithsImages/",

I don't have a problem.  



I explained that I tested various things including if I am using the exact folder location as mentioned. The result of using the exact location was that I did not have a problem. Or to put it another way, the files were uploading. For this reason, we know that there is nothing wrong with the folder permissions.

Therefore, the problem must lay in my input of the variable.

Originally Said By: martin389853
  'UploadFolder' => "". '$imageFolder' ."",  



Thanks for your response though.

Sign in to reply to this post

martin389853

I have now used the same variable, eg. $imageFolder, in the same page, once as an echo statement and once also to read all the files in that directory, eg.

$dir= "$imageFolder"; //<--define the directory to view.
$files = scandir($dir); //<--read all the images into an array.
$im_num = 0; //<--reset image number before count

foreach ($files as $image)
{
if(substr($image, 0, 1) != '.') //<--Ignore anything starting with a period.
{
$image_size = getimagesize("$dir/$image");
//<--Get the image's size in pixels.
$file_size = round( (filesize("$dir/$image")) /1024) . "kb";
//<--Calc size in kb.
$im_num = $im_num - 1;
//<--count every image in the folder.
$rev_im_num = $im_num*-1;

//<--Display the info.
echo "<tr>
<td>$rev_im_num</td>
<td>$image</td>
<td>$file_size</td>
</tr>";
}
}

So now I see the variable as a link so that I know how it looks. I also see if the link works because I get a list of the images in the file with file size. This means that the variable element is the correct file location. Knowing this and knowing that using the link (not the variable) directly in the WA_UploadResult script works, I must conclude that there is nothing wrong with the variable or the folder permissions.

I therefore conclude that WA_UploadResult is taking my variable and ... eating it. Bad boy WA_UploadResult. Only you guys know what your extension is doing and how it is doing it so only you can tell me why your script is turning my variable into air. thanks for listening.

Sign in to reply to this post

anonymous

Martin,

After closer look, you actually have an error in your PHP


$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "". '$imageFolder' ."",

Notice, you have single quotes around your variable... that tells PHP to show the text exactly as it is typed and not process it as a variable.

Your variable should actually be this:

$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "". $imageFolder ."",


You could enclose the variable inside double quotes because that tells PHP that processing is required inside the string. The only time where PHP processes something inside single quotes is inside a query statement.

Best regards,

Brian

Sign in to reply to this post

martin389853

Thank you kind sir!

I do get a little mixed up, especially when I've been looking at the same stuff for some time. Your correction there was exactly the ticket. Its on page 32 of my 'Php and Mysql' manual, single vs double quotation marks! haha.

I was thrown because I originaly wrote : 'UploadFolder' => $imageFolder,

Writing "". to me is saying 'Start string, End string, concatenate'. Starting and ending a string without a value is like saying 'nothing' and why would you concatenate nothing to that?

My problem is solved though, so thank you. However, if you were to enlighten me any further with an explanation of why you concatenated the double quotation marks, that would be a bonus. Again, many thanks.

Sign in to reply to this post

anonymous

Hey Martin,

I don't always do that practice, but a lot of programmers like to concatenate that way so they are explicitly ensuring that nothing is before or after what they are processing (especially when setting a lot of variables). The empty quote strings, in other words, will guarantee that there is nothing before or after.

Brian

Sign in to reply to this post

martin389853

I like your style. A trend is born :)

Thx again.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...