473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

PHP unable to Upload to Fileserver

Is there any one who could help with a problem. I have an application that uploads images to a file server with my upload directory set thus:[PHP]define('ALBUM_IMG_DIR', 'C:/Inetpub/wwwroot/sites/supportbridges/www/admin/profile/images/album/');[/PHP]

This is how it is on my local computer running on IIS, now I want to transfer the same application to a Linux host. What can I do to shorten the directory link so as to be able to upload images to the same folder: The upload folder is "album"
Dec 5 '06 #1
5 2611
Is there any one who could help with a problem. I have an application that uploads images to a file server with my upload directory set thus:[PHP]define('ALBUM_IMG_DIR', 'C:/Inetpub/wwwroot/sites/supportbridges/www/admin/profile/images/album/');[/PHP]

This is how it is on my local computer running on IIS, now I want to transfer the same application to a Linux host. What can I do to shorten the directory link so as to be able to upload images to the same folder: The upload folder is "album"
How funny this I used this example toturial last week. Any how you need to change from c:/inetpub to something more like /home/www.domain/

for the script to work. You must reflect the relitive path on the sever not your local computer.
Dec 5 '06 #2
Thanks for your help, I have set the relative part but it displays a blank page.

My relative path is: /var/www/html/domains/supportbridges.org/documentroot/sbi/images/album/

Please is there any suggestion why it keeps displaying a blank page instead of displayin the uploaded images.
Dec 6 '06 #3
It would be a big help if You showed the code because I can only guess...
Dec 6 '06 #4
Ok Thanks, here are the codes:
The code below is my code for config. It defines the upload directory and also the database connection:

[PHP]<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connx = "localhost";
$database_connx = "sbdb";
$username_connx = "root";
$password_connx = "sbdbadm1n";
$connx = mysql_pconnect($hostname_connx, $username_connx, $password_connx) or trigger_error(mysql_error(),E_USER_ERROR);

// an album can have an image used as thumbnail
// we save the album image here
define("ALBUM_IMG_DIR", "/var/www/html/domains/supportbridges.org/documentroot/sbi/images/album/
");

// all images inside an album are stored here
define("GALLERY_IMG_DIR", "/var/www/html/domains/supportbridges.org/documentroot/sbi/images/gallery/"); ;

// When we upload an image the thumbnail is created on the fly
// here we set the thumbnail width in pixel. The height will
// be adjusted proportionally
define('THUMBNAIL_WIDTH', 40);

// make a connection to mysql here
$connx = mysql_connect ($hostname_connx, $username_connx, $password_connx) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ($database_connx) or die ("I cannot select the database '$dbname' because: " . mysql_error());
?>[/PHP]

Now here is my functions code the handles the thumbnail creation and other stuff.

[PHP]<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connx = "localhost";
$database_connx = "sbdb";
$username_connx = "root";
$password_connx = "sbdbadm1n";
$connx = mysql_pconnect($hostname_connx, $username_connx, $password_connx) or trigger_error(mysql_error(),E_USER_ERROR);

// an album can have an image used as thumbnail
// we save the album image here
define("ALBUM_IMG_DIR", "/Inetpub/wwwroot/projects/support/images/album/");

// all images inside an album are stored here
define("GALLERY_IMG_DIR", "/Inetpub/wwwroot/projects/support/images/gallery/"); ;

// When we upload an image the thumbnail is created on the fly
// here we set the thumbnail width in pixel. The height will
// be adjusted proportionally
define('THUMBNAIL_WIDTH', 40);

// make a connection to mysql here
$connx = mysql_connect ($hostname_connx, $username_connx, $password_connx) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ($database_connx) or die ("I cannot select the database '$dbname' because: " . mysql_error());
?>[/PHP]

Now here is my add album code the adds new album to the fileserver and database.

[PHP]<?php
require_once '../library/config.php';
require_once '../library/functions.php';
if(isset($_POST['txtName']))
{
$albumName = $_POST['txtName'];
$albumDesc = $_POST['mtxDesc'];

$imgName = $_FILES['fleImage']['name'];
$tmpName = $_FILES['fleImage']['tmp_name'];

// we need to rename the image name just to avoid
// duplicate file names
// first get the file extension
$ext = strrchr($imgName, ".");

// then create a new random name
$newName = md5(rand() * time()) . $ext;

// the album image will be saved here
$imgPath = ALBUM_IMG_DIR . $newName;

// resize all album image
$result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH);

if (!$result) {
echo "Error uploading file";
exit;
}

if (!get_magic_quotes_gpc()) {
$albumName = addslashes($albumName);
$albumDesc = addslashes($albumDesc);
}

$query = "INSERT INTO tbl_album (al_name, al_description, al_image, al_date)
VALUES ('$albumName', '$albumDesc', '$newName', NOW())";

mysql_query($query) or die('Error, add album failed : ' . mysql_error());

// the album is saved, go to the album list
echo "<script>window.location.href='index.php?page= list-album';</script>";
exit;
}
?>

<form action="" method="post" enctype="multipart/form-data" name="frmAlbum" id="frmAlbum">
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="table_grey">
<tr>
<th width="150">Album Name</th>
<td width="80" bgcolor="#FFFFFF"> <input name="txtName" type="text" id="txtName"></td>
</tr>
<tr>
<th width="150">Description</th>
<td bgcolor="#FFFFFF"> <textarea name="mtxDesc" cols="50" rows="4" id="mtxDesc"></textarea>
</td>
</tr>
<tr>
<th width="150">Image</th>
<td bgcolor="#FFFFFF"> <input name="fleImage" type="file" class="box" id="fleImage"></td>
</tr>
<tr>
<td width="150" bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF"> <input name="btnAdd" type="submit" id="btnAdd" value="Add Album">
<input name="btnCancel" type="button" id="btnCancel" value="Cancel" onClick="window.history.back();"></td>
</tr>
</table>
</form>
[/PHP]

Now here is the page it ought to link to, the list-album page.

[PHP]<?php
$albumPerPage = 10;

$pageNumber = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;

$offset = ($pageNumber - 1) * $albumPerPage;
$serial = $offset + 1;

$sql = "SELECT al_id, al_name, al_image, COUNT(im_album_id) AS al_numimage
FROM tbl_album al LEFT JOIN tbl_image im ON al.al_id = im.im_album_id
GROUP by al_id
ORDER BY al_name ";
$result = mysql_query($sql . "LIMIT $offset, $albumPerPage") or die('Error, list album failed. ' . mysql_error());

?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="table_grey">
<tr>
<th width="30" align="center">#</th>
<th align="center">Album Name</th>
<th width="120" align="center"> Images</th>
<th width="60" align="center">&nbsp;</th>
<th width="60" align="center">&nbsp;</th>
</tr>
<?php
if (mysql_num_rows($result) == 0) {
?>
<tr bgcolor="#FFFFFF">
<td colspan="5">No album yet</td>
</tr>
<?php
} else {
$serial = $offset + 1;
while ($row = mysql_fetch_assoc($result)) {
extract($row);

$al_numimage = "<a href=\"?page=list-image&album=$al_id\">$al_numimage</a>";
?>
<tr bgcolor="#FFFFFF">
<td width="30" align="center"><?php echo $serial++; ?></td>
<td align="center"><a href="?page=album-detail&alId=<?php echo $al_id; ?>"><img src="../viewImage.php?type=album&name=<?php echo $row['al_image']; ?>" border="0" /><br />
</a><a href="?page=album-detail&amp;alId=<?php echo $al_id; ?>"><?php echo $al_name; ?></a></td>
<td width="120" align="center"><?php echo $al_numimage; ?></td>
<td width="60" align="center"><a href="?page=modify-album&alId=<?php echo $al_id; ?>">Modify</a></td>
<td width="60" align="center"><a href="javascript:deleteAlbum(<?php echo $al_id; ?>);">Delete</a></td>
</tr>
<?php
} // end while
}
?>
<tr bgcolor="#FFFFFF">
<td colspan="5" align="center"><?php
$result = mysql_query($sql);
$totalResults = mysql_num_rows($result);

echo getPagingLink($totalResults, $pageNumber, $albumPerPage, "page=list-album");
?>&nbsp;</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="5" align="right"><input type="button" name="btnAdd" value="Add Album" onclick="window.location.href='index.php?page=add-album';" /></td>
</tr>
</table>

[/PHP]

Please help, thanks.
Dec 7 '06 #5
// resize all album image
$result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH);
I couldn't find the createThumbnail function anywhere. Is there more code than what you posted?

Sean
Dec 8 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marco Aschwanden | last post by:
Hi I would like to install Python on a fileserver. All the machines (all Win2K) should afterwards use this Python installation. The (Python) apps I am developing will be as well placed on the...
1
by: Hrvoje Vrbanc | last post by:
Hello all, I have a web server in a domain and would like to upload files using an ASP.NET application that resides on the aforementioned server but the destination folder for upload is a shared...
1
by: Adam aku | last post by:
Hi! I suppose this is an easy problem but despite searching through manuals I have not as yet been able to solve it I have a asp .net web form which needs to access files from our fileserver. The...
0
by: foozhiqin | last post by:
Hi All, I have a program to for user to upload file into server with the form appliation. Can anyone advise me if i should save the file into FileServer or save into SQL database as byte...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
0
by: ll | last post by:
I'm working with 'pure ASP upload' script which is designed to redirect to an alert/error message, should a file larger than the set limit be attempted to be uploaded. The problem is that, while...
5
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.